STM32F405 Multiple ADC multiple channels DMA problem
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-27 7:02 AM
Hi all, I am desperately trying to sample 15 ADC channels using the 3 ADCs of the F405.
First I tried using the multi ADC triple mode, with 5 channels set for each ADC. I used DMA to transfer data to memory. It seems to work, but I get garbage data in memory.
Then, as an alternate solution, I decided to use the 3 ADCs in independent mode and perform 3 ADC scans of 5 channels on the 3 ADCs, again with DMA.
Strangely, I only get one sample by each ADC instead of the 5 expected. Every DMA calls the HAL_ADC_ConvCplCallback as it should, but memory contains only this one sample value. Every ADC also has the overrun bit set in its status register.
I do not understand what is wrong.
My setup is : my own board using a STM32F405. I use CubeMX and the HAL with FreeRTOS.
Attached the main.c and .ioc files showing the init of the ADC, DMA and start of the ADC with DMA.
Thanks in advance for your help.
- Labels:
-
STM32F4 Series
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2025-02-27 6:07 PM
Your code shows your Length as 1 instead of 5
if(HAL_ADC_Start_DMA(&hadc1, (uint32_t*)ADCValues_1, 1) != HAL_OK)
Error_Handler();
if(HAL_ADC_Start_DMA(&hadc2, (uint32_t*)ADCValues_2, 1) != HAL_OK)
Error_Handler();
if(HAL_ADC_Start_DMA(&hadc3, (uint32_t*)ADCValues_3, 1) != HAL_OK)
Error_Handler();
/**
* @brief Enable ADC, start conversion of regular group and transfer result through DMA.
* @note Interruptions enabled in this function:
* overrun (if applicable), DMA half transfer, DMA transfer complete.
* Each of these interruptions has its dedicated callback function.
* @PAram hadc ADC handle
* @PAram pData Destination Buffer address.
* @PAram Length Number of data to be transferred from ADC peripheral to memory
* @retval HAL status.
*/
HAL_StatusTypeDef HAL_ADC_Start_DMA(ADC_HandleTypeDef *hadc, uint32_t *pData, uint32_t Length)
TimerCallback tutorial! | UART and DMA Idle tutorial!
If you find my solution useful, please click the Accept as Solution so others see the solution.
