您的位置 首页 主动

深化了解ARM系统架构(S3C6410)—PWM实例

S3C6410X中有5个定时器,这些定时器产生内部中断。其中,Timer0和Timer1具有PWM功能,而Timer2,3,4没有此功能。TheS3C6410XRISCmicro…

S3C6410X中有5个守时器,这些守时器发生内部中止。其间,Timer0和Timer1具有PWM功用,而Timer2,3,4没有此功用。

The S3C6410X RISC microprocessorcomprises of five 32-bit timers. These timers are used to generate internal interruptsto the ARM subsystem. In addition, Timers 0 and 1 include a PWM function (PulseWidth Modulation),which can drive an external I/O signal. The PWM for timer 0and 1 have an optional dead-zone generator capability, which can be utilized tosupport a large current device. Timer 2, 3 and 4 are internal timers with no outputpins.

PWM具有两种操作形式:主动装载形式,一次触发形式。为完结PWM功用,芯片供给了16个功用寄存器。这些功用寄存器都衔接APB总线

整体架构图如下:

S3C6410X中有5个守时器,这些守时器发生内部中止。其间,Timer0和Timer1具有PWM功用,而Timer2,3,4没有此功用。守时器具有双缓冲特性,这样就能在不中止当时守时器操作的情况下,为下次守时器运转装入新的数值。虽然为守时器设置了新数值,但当时的守时操作能够成功完结。守时器从TCNTBn读取的值是为下次延时守时用的,并不影响当时守时器的运转。当TCNTn减小到0的时分,TCNTBn的值会主动复制到TCNTn中,这就是说的主动装载操作。守时器的当时技能数值能够从守时计数调查寄存器中TCNTOn读取。假如TCNTn为0且从装载也为0的话则TCNTn不在进行下次操作。

寄存器介绍:

1、总寄存器映射图

2、TCFG0寄存器:

3、TCFG1寄存器:

4、TCON操控寄存器:

mini6410蜂鸣器原理图:

界说寄存器:

  1. #definerTCFG0(*(volatileunsigned*)(0x7F006000))
  2. #definerTCFG1(*(volatileunsigned*)(0x7F006004))
  3. #definerTCON(*(volatileunsigned*)(0x7F006008))
  4. #definerTCNTB0(*(volatileunsigned*)(0x7F00600C))
  5. #definerTCMPB0(*(volatileunsigned*)(0x7F006010))
  6. #definerTCNTO0(*(volatileunsigned*)(0x7F006014))
  7. #definerTCNTB1(*(volatileunsigned*)(0x7F006018))
  8. #definerTCMPB1(*(volatileunsigned*)(0x7F00601c))
  9. #definerTCNTO1(*(volatileunsigned*)(0x7F006020))
  10. #definerTCNTB2(*(volatileunsigned*)(0x7F006024))
  11. #definerTCNTO2(*(volatileunsigned*)(0x7F00602c))
  12. #definerTCNTB3(*(volatileunsigned*)(0x7F006030))
  13. #definerTCNTO3(*(volatileunsigned*)(0x7F006038))
  14. #definerTCNTB4(*(volatileunsigned*)(0x7F00603c))
  15. #definerTCNTO4(*(volatileunsigned*)(0x7F006040))
  16. #definerTINT_CSTAT(*(volatileunsigned*)(0x7F006044))

编写初始化函数:

  1. voidinit_pwm()
  2. {
  3. rGPFCON&=~(0x3U<<28);
  4. rGPFCON|=(0x2U<<28);
  5. rTCFG0&=~0xff;
  6. rTCFG0|=(501);
  7. rTCFG1=0x4;
  8. #definefreq800
  9. rTCNTB0=(133000000/50/16)/freq;
  10. rTCMPB0=rTCNTB0/2;
  11. rTCON&=~0x1f;
  12. rTCON|=0xb;//disabledeadzone,auto-reload,inv-off,updateTCNTB0&TCMPB0,starttimer0
  13. rTCON&=~2;//clearmanualupdatebit
  14. }

在main函数中:

  1. init_pwm();
  2. while(1);

声明:本文内容来自网络转载或用户投稿,文章版权归原作者和原出处所有。文中观点,不代表本站立场。若有侵权请联系本站删除(kf@86ic.com)https://www.86ic.net/ziliao/zhudong/277022.html

为您推荐

联系我们

联系我们

在线咨询: QQ交谈

邮箱: kf@86ic.com

关注微信
微信扫一扫关注我们

微信扫一扫关注我们

返回顶部