cancel
Showing results for 
Search instead for 
Did you mean: 

what is the timing diagram about writing TIMx_CNT register

Yang Yang
Associate II

Hello, ST expert

 

STM32F407 is used for our custom design. And htim2 play the role of precise timing base.

When htim2->Instance.CNT = xx  is used for setting a new counter start value for timer2, it seems that the new counter value does not functions immediately, I mean that the next counter value does not appear one clock period later. 

Is there any timing diagram when TIMx_CNT register is written by user program?

 

BR

Yang

11 REPLIES 11
BarryWhit
Lead II

@Tesla DeLorean do you remember the thread JW mentioned? I'd like to read it.

 

Update:

but be aware of that that delta is off by an undocumented value (one or two cycles)

I wouldn't have expected it to be even that good, since the external signal is async to the STM32 clock domain. There has to be a synchronizer somewhere in the path (even if you were using an FPGA) and that is fundamentally non-deterministic.  Any fixed (systematic) error can be compensated for, sometimes even for free (for example by tweaking some threshold constants in a conditional). If it's a couple of cycles it's usually not an issue.

In the stated application (GPS PPS) the external interrupt apparently has a nominal period of 1 second. So way way not an issue. Still good to know.

- If someone's post helped resolve your issue, please thank them by clicking "Accept as Solution".
- Please post an update with details once you've solved your issue. Your experience may help others.