stm8l定时器中的ARPE

• Auto-reload preload enabled (ARPE bit set in the TIM1_CR1 register). In this mode,
when data is written to the auto-reload register, it is kept in the preload register and
transferred into the shadow register at the next update event (UEV).
• Auto-reload preload disabled (ARPE bit cleared in the TIM1_CR1 register). In this
mode, when data is written to the auto-reload register it is transferred into the shadow
register immediately.

我的理解是,当前0到10000计数,计的过程中,若修改了ARR的值。则有不同行为

1. ARPE=1时, 把设置的新值放到一个预加载寄存器,等到计到10000时,产生UEV事件,UEV事件会导致预加载寄存器的值写入ARR。也即当前计完,再说新的。

2. ARPE=0时,把设置的新值直接放到ARR里,这样的话,当前的计时周期就可能有问题,比如说,计到300,突然由10000改为1000。则计到1000就直接更新了。这个结果可能不是我们想要的。

所以,默认来说ARPE=1还是有用的。当然对运行过程中从来不改变ARR的程序,该设置起不到任何作用。

原文地址:https://www.cnblogs.com/javado/p/7628128.html