微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > 深入理解ARM体系架构(S3C6410)---PWM实例

深入理解ARM体系架构(S3C6410)---PWM实例

时间:11-09 来源:互联网 点击:
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&=~(0x3U28);
  4. rGPFCON|=(0x2U28);
  5. rTCFG0&=~0xff;
  6. rTCFG0|=(50-1);
  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);


Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top