cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F030C6T6_ADC_DMA

baskar
Associate II
Posted on December 12, 2015 at 08:18

we are configured the ADC1 ADC_CHANNEL_8 & ADC_CHANNEL_9 in DMA mode using STM32CUBMX version 4.0 for MDK-ARM.

But the ADC value are not updated in the user buffer,please help me how to configure the ADC using DMA mode.

int main(void)

{

static uint32_t adc__user_buffer[2]={0};

uint8_t pData[15]={0};

/* 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_ADC_Init();

MX_TIM3_Init();

MX_USART1_UART_Init();

HAL_ADC_MspInit(&hadc);

memset(adc__user_buffer,0,sizeof(adc__user_buffer));

HAL_ADC_Start_DMA(&hadc,(uint32_t*) adc__user_buffer, 2);

/* USER CODE BEGIN 2 */

/* USER CODE END 2 */

/* Infinite loop */

/* USER CODE BEGIN WHILE */

while (1)

{

/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */

memset(pData,0,sizeof(pData));

sprintf(pData,''ADC1 %4lu\r\n'',adc__user_buffer[0]);

HAL_UART_Transmit(&huart1, pData, strlen(pData),5);

memset(pData,0,sizeof(pData));

sprintf(pData,''ADC2 %4lu\r\n'',adc__user_buffer[1]);

HAL_UART_Transmit(&huart1, pData, strlen(pData),5);

HAL_Delay(1000);

}

/* USER CODE END 3 */

}

0 REPLIES 0