stm32cube测试ADC问题转换结果不准确.
大家好,使用stm32cube测试单通道ADC发现转换后的结果不准,相差了300mv左右,而使用库版本程序测试转换电压正常.
cube设置如图,主程序代码如下:
#include "stm32f1xx_hal.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_ADC1_Init(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
uint16_t ADC_ConvertedValue[1];
//extern ADC_HandleTypeDef hadc1;
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
/* USER CODE BEGIN 2 */
HAL_ADC_Start_DMA(&hadc1,(uint32_t *)ADC_ConvertedValue,1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
调试2天了,无果,希望做过的朋友帮忙看看.
cube设置如图,主程序代码如下:
#include "stm32f1xx_hal.h"
/* USER CODE BEGIN Includes */
/* USER CODE END Includes */
/* Private variables ---------------------------------------------------------*/
ADC_HandleTypeDef hadc1;
DMA_HandleTypeDef hdma_adc1;
/* USER CODE BEGIN PV */
/* Private variables ---------------------------------------------------------*/
/* USER CODE END PV */
/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_ADC1_Init(void);
/* USER CODE BEGIN PFP */
/* Private function prototypes -----------------------------------------------*/
/* USER CODE END PFP */
/* USER CODE BEGIN 0 */
uint16_t ADC_ConvertedValue[1];
//extern ADC_HandleTypeDef hadc1;
/* USER CODE END 0 */
int main(void)
{
/* USER CODE BEGIN 1 */
/* USER CODE END 1 */
/* MCU Configuration----------------------------------------------------------*/
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Configure the system clock */
SystemClock_Config();
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
MX_ADC1_Init();
/* USER CODE BEGIN 2 */
HAL_ADC_Start_DMA(&hadc1,(uint32_t *)ADC_ConvertedValue,1);
/* USER CODE END 2 */
/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */
/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}
调试2天了,无果,希望做过的朋友帮忙看看.
9 个回复
zznic
赞同来自:
zznic
赞同来自:
yingshi - www.ing10bbs.com
赞同来自: slyywd
我们的论坛有例程,测试过效果不错的
管理员认为我这些例程不要在这个论坛发,所以请你访问我们的论坛了解
萬~崧~霖 - IT男
赞同来自: 徐康
alexcnsz
赞同来自:
Chauncy&R
赞同来自:
想知道问题解决了吗?我最近也遇到了同样的问题
gh_3424
赞同来自:
日了狗了,外面采样IC给的电压非常稳定,精确到0.001v,但一转换就几百mv的蹦,200个采样数据滤波才能干到20mv范围,这不行啊
最后的守护者
赞同来自:
ken_wang
赞同来自:
在while 前面添加HAL_ADCEx_Calibration_Start(&hadc1);函数校准