2017-07-26 12:50 AM
Hi,
I'm using STM32F427ZI with FreeRTOS.
I am configuring both ADC1 and ADC3 to run using DMA, but I'm getting different behavior between them.
This is the configuration for ADC3, ADC1 is configuration the same:
ADC1 is configured to use DMA2 Stream 0, and ADC3 is configured to use DMA2 Stream 1.
This is configuration of DMA for ADC3. The configuration is the same for the DMA for ADC1.
After calling all init functions of the ADC and the DMA, I call the ADC Start DMA function:
result = HAL_ADC_Start_DMA(&hadc3, (uint32_t*)(adc3SamplesArray), 3);
If I call the function for ADC1, the DMA performs as expected and the callback is called.
If I call the function for ADC3, no call back is called, and the DMA doesn't seem to be doing anything.
What am I missing?
#adc #dmaSolved! Go to Solution.
2017-07-30 05:01 AM
Hello!
I can reproduce your error..
To solve it put 3/ threshold fifo at both dma channels (or less, depending your config).
Handle DMA overruns by implement HAL_ADC_ErrorCallback.
/**
* @brief Error ADC callback. * @note In case of error due to overrun when using ADC with DMA transfer * (HAL ADC handle paramater ''ErrorCode'' to state ''HAL_ADC_ERROR_OVR''): * - Reinitialize the DMA using function ''HAL_ADC_Stop_DMA()''. * - If needed, restart a new ADC conversion using function * ''HAL_ADC_Start_DMA()'' * (this function is also clearing overrun flag) * @param hadc: pointer to a ADC_HandleTypeDef structure that contains * the configuration information for the specified ADC. * @retval None */__weak void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc)2017-07-27 01:48 PM
Hi,
Have you enabled the clock used by ADC3?
Which CubeMx version are you using? Ensure that you are using the last version.
Regards
Imen
2017-07-30 02:29 AM
I'm using the latest versions of both the CubeMx and the firmware for the MCU I'm using.
I'll check if I enabled the clock for the ADC3, but I don't remember having to enable the clock to ADC1. Isn't that done automatically by CubeMx? I'm using code that was generated completely by CubeMx, without any hand-made changes.
In addition, my project is a migration of an old project that uses the old Standard Library on our board. I'm migrating the code to use the new HAL and LL API's for future migration to the F7, which doesn't have the old Standard Library API.
ADC3 worked on that board.
2017-07-30 03:44 AM
Hello!
You have the option to use HAL_ADC_ErrorCallbackADC_HandleTypeDef* hadc); and to take the error code .(hadc->ErrorCode)
Other option is to put a break to ADC_IRQHandler(); to see if ADC3 ISR is called.
You can also post your .IOC file (cubemx conf file) to help the community try to solve the problem.
2017-07-30 04:02 AM
I've checked hadc3. The state is static at 0x100 (BUSY) and the ErrorCode is 0.
I get the same behavior when running without the DMA.
Also the error callbacks, both with and without DMA are not called.
I've attached the IOC project.
________________ Attachments : FEC3.ioc.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyXU&d=%2Fa%2F0X0000000b9F%2F5lQ0LQRVsjAzsHJfk94IH6L3qBW3eGk24k5QU9uM5HU&asPdf=false2017-07-30 05:01 AM
Hello!
I can reproduce your error..
To solve it put 3/ threshold fifo at both dma channels (or less, depending your config).
Handle DMA overruns by implement HAL_ADC_ErrorCallback.
/**
* @brief Error ADC callback. * @note In case of error due to overrun when using ADC with DMA transfer * (HAL ADC handle paramater ''ErrorCode'' to state ''HAL_ADC_ERROR_OVR''): * - Reinitialize the DMA using function ''HAL_ADC_Stop_DMA()''. * - If needed, restart a new ADC conversion using function * ''HAL_ADC_Start_DMA()'' * (this function is also clearing overrun flag) * @param hadc: pointer to a ADC_HandleTypeDef structure that contains * the configuration information for the specified ADC. * @retval None */__weak void HAL_ADC_ErrorCallback(ADC_HandleTypeDef *hadc)2017-07-30 08:33 AM
Thanks. That did the trick.