深入理解ARM體系架構(S3C6410)—PWM執行個體

來源:互聯網
上載者:User

本系列文章由muge0913編寫,轉載請註明出處:http://blog.csdn.net/muge0913/article/details/7389801

作者:張同浩,郵箱:muge0913@sina.com



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蜂鳴器原理圖:

定義寄存器:

/* PWM Timer */#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 0rTCON &= ~2;//clear manual update bit}

在main函數中:

init_pwm();while(1);

程式:http://download.csdn.net/detail/muge0913/4170428

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.