cancel
Showing results for 
Search instead for 
Did you mean: 

Time delay when operating with DAC in STM32L4

GMate.2
Associate

Hi everyone!

I use 8 MHz external oscillator for my MCU. For TIM1 there is no prescaler in CUBE, so I expect this timer to tick with pure 8MHz frequency. And therefore I expect to see 0.125 us * 2 * 2 = 0.5 us period of signal. But actually I have 24 us period duration. What does slow down my DAC output? How can I achieve 0.5 us period for my pulse signal?

Thanks.
_legacyfs_online_stmicro_images_0693W00000bjWJcQAM.png
_legacyfs_online_stmicro_images_0693W00000bjWKGQA2.png
_legacyfs_online_stmicro_images_0693W00000bjWJhQAM.png

1 ACCEPTED SOLUTION

Accepted Solutions

fast_delay() alone takes a couple of instrucions = couple of cycles to call, and then return from it.

But, more importantly Cube/HAL functions are bloated, so HAL_DAC_SetValue may easily execute hundreds of instructions until it gets to write the value to DAC register and return.

JW

View solution in original post

3 REPLIES 3

fast_delay() alone takes a couple of instrucions = couple of cycles to call, and then return from it.

But, more importantly Cube/HAL functions are bloated, so HAL_DAC_SetValue may easily execute hundreds of instructions until it gets to write the value to DAC register and return.

JW

Thank you for the explanation

AScha.3
Chief II

try simple test : comment / leave away the fast_delay(); lines.

then you see the speed/delay of the HAL_Dac-set.. timing .

If you feel a post has answered your question, please click "Accept as Solution".