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蜂鸣器原理图:
界说寄存器:
- #define
rTCFG0 (*(volatile unsigned *)(0x7F006000)) - #define
rTCFG1 (*(volatile unsigned *)(0x7F006004)) - #define
rTCON (*(volatile unsigned *)(0x7F006008)) - #define
rTCNTB0 (*(volatile unsigned *)(0x7F00600C)) - #define
rTCMPB0 (*(volatile unsigned *)(0x7F006010)) - #define
rTCNTO0 (*(volatile unsigned *)(0x7F006014)) - #define
rTCNTB1 (*(volatile unsigned *)(0x7F006018)) - #define
rTCMPB1 (*(volatile unsigned *)(0x7F00601c)) - #define
rTCNTO1 (*(volatile unsigned *)(0x7F006020)) - #define
rTCNTB2 (*(volatile unsigned *)(0x7F006024)) - #define
rTCNTO2 (*(volatile unsigned *)(0x7F00602c)) - #define
rTCNTB3 (*(volatile unsigned *)(0x7F006030)) - #define
rTCNTO3 (*(volatile unsigned *)(0x7F006038)) - #define
rTCNTB4 (*(volatile unsigned *)(0x7F00603c)) - #define
rTCNTO4 (*(volatile unsigned *)(0x7F006040)) - #define
rTINT_CSTAT (*(volatile unsigned *)(0x7F006044))
编写初始化函数:
- void
init_pwm() - {
rGPFCON &= ~(0x3U << 28); rGPFCON |= (0x2U << 28); rTCFG0 &= ~0xff; rTCFG0 |= (50 – 1); rTCFG1 = 0x4; #define freq 800 rTCNTB0 = (133000000/50/16)/freq; rTCMPB0 = rTCNTB0/2; rTCON &= ~0x1f; rTCON |= 0xb; //disable deadzone, auto-reload, inv-off, update TCNTB0&TCMPB0, start timer 0 rTCON &= ~2; //clear manual update bit - }
在main函数中:
- init_pwm();
- while(1);