OK6410 PWM

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

 

 

 

关于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. 
 

 
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工作寄存器:

 

 

 

在TCFG1 (Timer Configuration Register) 中

 

在 TCON (Timer Control Register)中

 

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

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值