Study Notes 1

Timer basics

The STM32F4 timers are very powerful, with advanced timers such as TIME1 and TIME8, general timers such as TIME2-TIM5, TIM9~TIM14, and basic timers such as TIME6 and TIME7, making a total of 14 timers. However, we mainly focus on general-purpose timers in our daily life.

I. Timer Related Registers

  1. Counter Current Value Register CNT:
    This carries out the counting up and counting down of data, and stores the current count value of the timer.

  2. Prescaler register TIMx_PSC.
    The timer clock source is divided and output to reduce the frequency of the timer clock (CK_CNT) to obtain the desired timer clock frequency.

  3. Auto Reload Register TIMx_ARR.
    Stores the value required for reloading. Assuming downward counting, when the value in CNT reaches 0, the timer reads the value in ARR and assigns it to CNT to re-count. And when counting up, when the value in the CNT reaches the value set in advance in the ARR, it will terminate this count.

  4. Status register (TIMx_SR):
    This register is used to mark whether the various events/interrupts currently associated with the timer have occurred.

II Various parameters of the timer

1): Prescaler: Timer prescaler setting, the clock source passes through this divider before it is the timer clock, it sets the value of the TIMx_PSC register. It sets the value of the TIMx_PSC register. The value can be set from 0 to 65535 to achieve a frequency division from 1 to 65536.
2): CouterMode: the timer counting mode and controls whether the timer counts up, down or centre.
3): Period: the period of the timer, can be set from 0 to 65535. assume that in the timer pre-division we have got the clock after the division is 1MHz. the value of Period we set to 1000, so that the timer generate interrupt frequency is: 1MHz/1000=1KHz, which is 1ms timing period.
4): ClockDivision: clock division, set the timer clock CK_INT frequency and digital filter sampling clock frequency division ratio.
5): RepetitionCounter: Repetition counter, which is a special register bit for advanced control registers, and can be used to control the number of PWM outputs very easily.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值