NanoPi PWM驱动(Nanopi-S2)

本文详细介绍了NanoPi S2的PWM功能,包括定时器的工作原理、PWM的配置方法,以及如何利用mmap函数进行内存映射操作。PWM功能允许驱动外部I/O信号,具有死区生成能力,而定时器可从内部APB-PCLK或外部时钟源选择时钟。此外,还提供了初始化示例和GPIO映射操作。
摘要由CSDN通过智能技术生成
  • pwm相关手册说明

These timers can be used to generate internal interrupts to the ARM subsystem. In addition, Timers 0, 1, 2, and 3include a PWM function (Pulse Width Modulation) which can drive an external I/O signal. The PWM for timer 0 has a optional dead-zone generator capability, which can be utilized to support a large current device. Timer 4 is only an internal timer with no output pins.

这些定时器在ARM子系统中产生一个内部中断。另外,定时器0、1、2、3包含一个PWM功能,来驱动一个外部I/O信号。PWM定时器0有一个支持死区发生器能力,支持大电流设备,定时器4是一个内部定时器,没有引脚输出。

The Timers are normally clocked off of a divided version of the APB-PCLK. Timers 0 and 1 share a programmable 8-bit prescaler that provides the first level of division for the PCLK. Timer 2, 3, and 4 share a different 8-bit prescaler. Each timer has its own, private clock-divider that provides a second level of clock division (prescaler divided by 2, 4, 8, or 16). Alternatively, the Timers can also select a clock source from an external pin, except Timer 4. Timers 0 and 1 can select the external clock TCLK0. Timers 2 and 3 can select the external clock TCLK1. Timer 4 operates with APB-PCLK only.

定时器通常由APB-PCLK的分频提供时钟。定时器0和1共享一个可编程的8位预分频器,为PCLK提供第一级分频。 定时器2、3和4共享一个不同的8位预分频器。每个定时器都有自己的专用时钟分频器,提供第二级时钟分频(预分频器除以2,4,8或16)。除定时器4外,定时器还可从外部引脚选择一个时钟源。定时器0和1可选择外部时钟TCLK0。 定时器2和3可以选择外部时钟TCLK1。 定时器4仅使用APB-PCLK进行操作。

Each timer has its own 32-bit down-counter which is driven by the timer clock. The down-counter is initially loadedfrom the Timer Count Buffer register (TCNTBn). When the down-counter reaches zero, the timer interrupt requestis generated to inform the CPU that the timer operation is completed. When the timer down-counter reaches zero,the value of corresponding TCNTBn can be automatically reloaded into the down-counter to start the next cycle.However, if the timer stops, for example, by clearing the timer enable bit of TCONn during the timer running mode, the value of TCNTBn is not reloaded into the counter.

每个定时器都有自己的32位递减计数器,由定时器时钟驱动。 递减计数器最初从定时器计数缓冲寄存器(TCNTBn)加载。 当减计数器达到零时,产生定时器中断请求以通知CPU定时器操作完成。 当定时器减计数器达到零时,对应的TCNTBn的值可以自动重新加载到减计数器中以开始下一个循环。然而,如果定时器停止,例如:在定时器运行模式下,清除定时器的使能位TCONn,TCNTBn的值是不能重加载到计数器的。

The Pulse Width Modulation function (PWM) uses the value of the TCMPBn register. The timer control logic changes the

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值