stm32 timer preload register and shadow register

1. What are preload registers and shadow registers?

In the stm32 timer block diagram, there are black shadows under some registers (green box in the picture below)

Such as automatic reloading register, the explanation is:

This register actually has 2 registers: preload register + shadow register

The preload register is a register used by users to configure (used by users to read and write values), while the shadow register is the register that actually works (that is, what is said in the red box in the picture above)


The text in the red box in the picture above has an important point: according to the setting of the control bit

explain:

For example, in the auto-reload register, there is a register called ARPE (auto-load preload enable bit). If this register is not enabled, after modifying the value of the auto-reload register (actually the preload register is modified), The value of the preload register is immediately updated to the shadow register (i.e., the working register).

On the contrary, if the ARPE register is enabled, after the user modifies the value of the automatic reload register (actually modifying the preload register), the value of the preload register will wait until the end of this counting cycle (that is, the counter overflows, triggering an update event), the value is updated to the shadow register (that is, the working register)

2. cubemx related configuration

After enabling auto-reload preload, after modifying the value of the ARR register (that is, modifying the preload register of the auto-reload register), it will not be updated immediately to the relevant shadow register (working register), but will be updated at the end of this PWM cycle. Later (that is, the counter overflows and an update event is triggered), it is updated to the relevant shadow register (working register); otherwise, the relevant shadow register (working register) is updated immediately.

After output compare preload is enabled, after modifying the value of the CCR register (that is, modifying the preload register of the automatic reload register), it will not be updated to the relevant shadow register (working register) immediately, but after the end of this PWM cycle. (That is, the counter overflows, triggering an update event) updated to the relevant shadow register (working register), otherwise, the relevant shadow register (working register) is updated immediately.

in:

ARR-->pwm cycle

CCR-->duty cycle

Not rigorous, rough understanding

 

 

Guess you like

Origin blog.csdn.net/qq_62573253/article/details/131217073