STM32L011K4 DMA ADC 采集发现数组隔一个才有数据????

QQ截图20180330171232.jpg

上面的例子是仿照STM32L011K4-Nucleo 中的ADC_DMA_Transfer 例子来用MX 配置的,可以发现仿真的时候出现了数据断层的现象,用官网的却全部都填满数据,有大神知道这是什么情况吗? 附MX的配置。麻烦大家帮忙看下,共同进步,小弟感激不尽!!!

ADC_TEST.rar

/* USER CODE BEGIN 0 */

#define ADC_CONVERTED_DATA_BUFFER_SIZE   ((uint32_t)  32)   /* Size of array aADCxConvertedData[] */

uint16_t   aADCxConvertedData[ADC_CONVERTED_DATA_BUFFER_SIZE];

/* USER CODE END 0 */


ADC_HandleTypeDef hadc;

DMA_HandleTypeDef hdma_adc;


/* ADC init function */

void MX_ADC_Init(void)

{

  ADC_ChannelConfTypeDef sConfig;


    /**Configure the global features of the ADC (Clock, Resolution, Data Alignment and number of conversion) 

    */

  hadc.Instance = ADC1;

  hadc.Init.OversamplingMode = DISABLE;

  hadc.Init.ClockPrescaler = ADC_CLOCK_SYNC_PCLK_DIV2;

  hadc.Init.Resolution = ADC_RESOLUTION_12B;

  hadc.Init.SamplingTime = ADC_SAMPLETIME_1CYCLE_5;

  hadc.Init.ScanConvMode = ADC_SCAN_DIRECTION_FORWARD;

  hadc.Init.DataAlign = ADC_DATAALIGN_RIGHT;

  hadc.Init.ContinuousConvMode = ENABLE;

  hadc.Init.DiscontinuousConvMode = DISABLE;

  hadc.Init.ExternalTrigConvEdge = ADC_EXTERNALTRIGCONVEDGE_NONE;

  hadc.Init.ExternalTrigConv = ADC_SOFTWARE_START;

  hadc.Init.DMAContinuousRequests = ENABLE;

  hadc.Init.EOCSelection = ADC_EOC_SINGLE_CONV;

  hadc.Init.Overrun = ADC_OVR_DATA_OVERWRITTEN;

  hadc.Init.LowPowerAutoWait = DISABLE;

  hadc.Init.LowPowerFrequencyMode = DISABLE;

  hadc.Init.LowPowerAutoPowerOff = DISABLE;

  if (HAL_ADC_Init(&hadc) != HAL_OK)

  {

    Error_Handler();

  }


    /**Configure for the selected ADC regular channel to be converted. 

    */

  sConfig.Channel = ADC_CHANNEL_0;

  sConfig.Rank = ADC_RANK_CHANNEL_NUMBER;

  if (HAL_ADC_ConfigChannel(&hadc, &sConfig) != HAL_OK)

  {

    Error_Handler();

  }

 /* ### - 2 - Start calibration ############################################ */

  if (HAL_ADCEx_Calibration_Start(&hadc, ADC_SINGLE_ENDED) !=  HAL_OK)

  {

    Error_Handler();

  }

 /* ### - 4 - Start conversion in DMA mode ################################# */

  if (HAL_ADC_Start_DMA(&hadc,

                        (uint32_t *)aADCxConvertedData,

                        ADC_CONVERTED_DATA_BUFFER_SIZE

                       ) != HAL_OK)

  {

    Error_Handler();

  }


}


已邀请:

绿意py

赞同来自:

你好,请问有找到原因吗?遇到同样的问题了

要回复问题请先登录注册