OK6410之蜂鸣器驱动硬件分析---PWM定时器

    在OK6410开发板中,蜂鸣器的IO口为GPF15

 

OK6410之蜂鸣器驱动硬件分析---PWM定时器_第1张图片OK6410之蜂鸣器驱动硬件分析---PWM定时器_第2张图片

 

 

关于GPF15的GPIO详细参考S3C6410的PDF手册

GPF14 [29:28] 00 = Input       01 = Output   10 = PWM TOUT[0]  11 = CLKOUT[0] 
GPF15 [31:30] 00 = Input        01 = Output  10 = PWM TOUT[1]  11 = Reserved

重点介绍PWM定时器工作:

S3C6410X中有5器,些定部中。其中,Timer0和Timer1具有PWM功能,而Timer2,3,4有此功能

PWM具有两种操作模式:自模式,一次触发模式。为实现PWM功能,芯片提供了16功能寄存器。些功能寄存器都APB总线

器具有双缓冲特性,这样就能在不停止前定器操作的情下,下次定行装入新的数值置了新数值,但前的定操作能成功完成。定TCNTBn取的下次延用的,不影响当前定器的行。TCNTn小到0候,TCNTBn值会动复制到TCNTn中,就是的自操作。定器的前计数值可以时计数观察寄存器中TCNTOn取。如果TCNTn00话则TCNTn不在行下次操作

在S3C6410的PDF手册中介绍PWM的工作流程:

The Pulse Width Modulation function (PWM) uses the value of the TCMPBn register. The timer control logic
changes the output level when the down-counter value matches the value of the compare register in the timer
control logic. Therefore, the compare register determines the turn-on time (or turn-off time) of a PWM output. 
The TCNTBn and TCMPBn registers are double buffered to allow the timer parameters to be updated in the
middle of a cycle. The new values will not take effect until the current timer cycle completes.
A simple example of a PWM cycle is shown in the figure below.
 

OK6410之蜂鸣器驱动硬件分析---PWM定时器_第3张图片

 
1.  Initialize the TCNTBn with 159(50+109) and the TCMPBn with 109. 
2.  Start Timer by setting the start bit and manual update bit off.
The TCNTBn value of 159 is loaded into the down-counter, the output is driven low.
3.  When down-counter counts down to the value in the TCMPBn register 109,
the output is changed from low to high
4.  When the down-counter reaches 0, the interrupt request is generated. 
5.  The down-counter is automatically reloaded with TCNTBn, which restarts the cycle.

对于PWM 功能,要用到寄存器TCMPBn,当递减计数器down-counter的值和比较寄存器TCMPBn的值相同时,定时控制逻辑模块就会改变输出电平。因此比较寄存器TCMPBn决定了PWM的输出。

 

 

定时器0工作寄存器:

OK6410之蜂鸣器驱动硬件分析---PWM定时器_第4张图片

 

 OK6410之蜂鸣器驱动硬件分析---PWM定时器_第5张图片

 

在TCFG1 (Timer Configuration Register) 中

 

在 TCON (Timer Control Register)中

OK6410之蜂鸣器驱动硬件分析---PWM定时器_第6张图片

 

见下一篇:OK6410之蜂鸣器驱动软件分析---PWM定时器

http://blog.csdn.net/sun_rise2011/article/details/7978395

 

你可能感兴趣的:(timer,工作,function,input,Parameters,output)