Time delay when operating with DAC in STM32L4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-06 6:33 AM - edited ‎2023-11-20 6:15 AM
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.
Solved! Go to Solution.
- Labels:
-
DAC
-
STM32L4 series
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-06 9:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-06 9:23 AM
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-07 6:45 AM
Thank you for the explanation
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2023-05-07 6:59 AM
try simple test : comment / leave away the fast_delay(); lines.
then you see the speed/delay of the HAL_Dac-set.. timing .
