AnsweredAssumed Answered

F407 - ADC/DAC at 400 kHz and UART using HAL?

Question asked by taprok on Nov 2, 2016
Latest reply on Nov 3, 2016 by ST Renegade
Hi all,

i think i am experiencing a timing issue here. I configured the STM32F407 using CubeMX and the latest HAL FW Package. I set the clocks to max using HSE (8 MHz) with PLL to run HCLK with 168 MHz and maxed APB peripherals (42/84 MHz).

I configured DMA for UART 1, ADC and DAC. The ADC and DAC are getting triggered by TIM2 Output Event signal at 400 kHz.

DAC is running in circular mode with only 4 values of a 100 kHz "sine" wave - so i expected the peripheral to run "on its own".
The ADC is connected to the same TIM2 TRGO Event and therefore should sample at 400 kHz. I require the ADC to take for example 200 samples with the 400 kHz sampling rate.

I am calling the ADC using:
HAL_ADC_Start_DMA(&hadc1, adc1vals, 200);

The  HAL_ADC_ConvCpltCallback does nothing but to send back the values using UART:
HAL_UART_Transmit_DMA(&huart1, adc1vals, 200);

Everything works just fine on its own, but putting it all together it stops working and the uart becomes "deaf". Let me explain this a little further:

After the MCU startup i start the DAC using

HAL_DAC_Start_DMA(&hdac, DAC1_CHANNEL_1,  sinValues, 4, DAC_ALIGN_12B_R);

and see the correct signal on the corresponding pin. The UART is responsive and working in both directions. When i send the command to start the adc conversion, nothing happens and the uart becomes inresponsive so all i can do is reset the mcu. But the DAC signal is still on the pin.

Using the debugger, i see that the adc starts conversion but the software seems to be in a strange loop somewhere inside the DMA Interrupt routines (there is no specific point, the code doesnt "stop") and gets "lost" inside the HAL routines. The UART interrupt is called if a send a command, if i set a breakpoint in the callback routine it stops, but the data received never gets evaluated (but i can "see" it in the array i specified as rx-array). Neither in the ADC nor UART  status registers any error states are getting set except the OVR bit as soon as i stop the code with the debugger. If i check the OVR bits in the main loop with a debug LED it doesn't seem to be set.

I am not too experienced with debugging timing issues but i am wondering if it would be possible that the long Interrupt routines provided by the HAL driver somehow create these problems? Before i try to modify the code from HAL (what i really try to avoid because i do not fully understand the details ) i just wanted to ask if there is any known timing issues or limitations to this applications.
The datasheet says adc 2.4 MSPs and dac up to 555kHz without external opamp circuit (DAC application note).

I hope this is not too confusing, i pasted  the relevant parts of the init-code cube mx generated here: http://pastebin.com/xuF52W7W
 

Thanks in advance for help,

best regards :)

edit: i forgot, i am not using FIFO as mentioned in errata sheet and of course not the DCMI.



Outcomes