cancel
Showing results for 
Search instead for 
Did you mean: 

I am Going To Generate 10us delay for ultrasonic sensor in STM32L152RET ,HAL_Delay() is Create Delay Upto ms,How It Can Generate?

KisanKale
Associate
 
5 REPLIES 5

Use a free running TIM at 1 MHz or faster, and delta the count, or use the DWT CYCCNT register, it is 32-bit and counts processor cycles, so good to a few 10's of nanoseconds in most cases.

Definitely don't use interrupts.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Apropos DWT - it belongs to the debug module (or whatever it is called)?

Is it still available when the debugger interface is disabled, such as in RDP level 2?

-- pa

KisanKale
Associate

0690X00000Bw97GQAR.pngthis is our program and it is getting stuck into the dummy while loop...why dose this happen.as we have observed,stm32l152ret always gets stuck in dummy loops..why is this so?

The unit is there with/without the debugger, it is an option on the core, but ST has it on all the CM3, CM4 and CM7 parts.

Using CM3 cores where the ROM gets patched via FPB in normal usage situations.

Pretty sure RDP 2 just gates access to the pins, it would get far more technically involved to interfere with the core.

You know it's not hard to test ones own hypothesis.

If concerned use TIM2 or TIM5, 32-bit on most of the cores worth using. For short duration stuff the 16-bit would also be serviceable.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

>>why is this so?

Why must one guess? Debug the code, have a HardFault_Handler() output actionable data, avoid unbounded while() loops. Have ErrorHandler() report a file and a line number

For the DWT make sure it is initialized.

If the debugger drops the connection look for WFI or low power modes turning OFF the pins and debug interface.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..