2020-01-17 04:05 AM
2020-01-17 04:09 AM
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.
2020-01-17 04:35 AM
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
2020-01-17 05:11 AM
2020-01-17 05:34 AM
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.
2020-01-17 05:40 AM
>>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.