GNU ARM匯編--(八)s3c2440的watchdog
照舊,給出s3c2440的datasheet說(shuō)明:
本文引用地址:http://butianyuan.cn/article/201611/321723.htm概述:
watchdog timer用于由于噪聲或者系統(tǒng)錯(cuò)誤引起的程序跑飛了的情況下恢復(fù)處理器的正常操作.它可以被用作一個(gè)可以請(qǐng)求中斷服務(wù)的普通16bit的內(nèi)部定時(shí)器.watchdog timer產(chǎn)生128 PCLK的重啟信號(hào).
特點(diǎn):
有中斷請(qǐng)求的普通內(nèi)部定時(shí)器模式
當(dāng)定時(shí)器計(jì)數(shù)為0(超時(shí))時(shí),產(chǎn)生內(nèi)部的長(zhǎng)達(dá)128PCLK周期的重啟信號(hào)
watchdog timer的操作:
F18-1顯示watchdog timer的功能框圖.watchdog timer只使用PCLK作為它的時(shí)鐘源.PCLK先由一個(gè)8bit的prescaler進(jìn)行分頻,接下來(lái)還會(huì)再次分頻.
Prescaler的值和分頻因子由watchdog timer控制寄存器(WTCON)決定.有效的預(yù)分頻值的范圍是(0--2^8-1),因?yàn)槭?bit的分頻器.分頻因子可選為16,32,64,128.
WTDAT&WTCNT
一旦watchdog timer啟用了,watchdog timer數(shù)據(jù)寄存器(WTDAT)的值不會(huì)自動(dòng)的重新加載到計(jì)數(shù)寄存器(WTCNT).所以,在watchdog timer啟動(dòng)前一定要向watchdog timer的計(jì)數(shù)寄存器(WTCNT)中寫(xiě)入一個(gè)初始值.
watchdog timer special registers
WTCON
WTCON允許user打開(kāi)或關(guān)閉watchdog timer,從4個(gè)不同的源中選擇時(shí)鐘信號(hào),開(kāi)關(guān)中斷以及開(kāi)關(guān)watchdog timer的輸出.watchdog timer用來(lái)s3c2440啟動(dòng)后的重啟,如果不想處理器重啟,watchdog timer要被禁用.在loader開(kāi)始時(shí),watchdog timer又沒(méi)初始化的時(shí)候,應(yīng)該將watchdog timer禁用.
如果user想使用watchdog timer提供的正常定時(shí)器功能,那就打開(kāi)中斷,關(guān)閉watchdog timer.
Register Address R/W Description Reset Value
WTCON 0x53000000 R/W Watchdog timer control register 0x8021
Bit Descrition Initial State
Prescaler value [15:8] 預(yù)分頻的值(0--255) 0x80
Watchdog timer [5] watchdog timer的開(kāi)關(guān)位 1(開(kāi))
Clock select [4:3] 時(shí)鐘分頻因子 00:16 01:32 00
10:64 11:128
Interrupt generation [2] 中斷的開(kāi)關(guān)位 0
Reset enable/diaable [0] 輸出重啟信號(hào)的開(kāi)關(guān) 1
WTDAT
WTDAT用來(lái)指定超時(shí)的期限.在最開(kāi)始的操作中WTDAT的值不會(huì)自動(dòng)的加載到計(jì)數(shù)器中.使用初始值0x8000就可以驅(qū)動(dòng)第一次超時(shí).以后的話(huà),WTDAT的值就會(huì)自動(dòng)重加載到WTCNT中.
Register Address R/W Description Reset Value
WTDAT 0x53000004 R/W Watchdog timer data register 0x8000
Bit Description Initial State
Count reload value [15:0] 重加載的計(jì)數(shù)值 0x8000
WTCNT
WTCNT包含正常操作下watchdog timer的當(dāng)前計(jì)數(shù)值.值得注意的是,在watchdog timer最初被啟用的時(shí)候,WTDAT的內(nèi)容不會(huì)自動(dòng)的加載到WTCNT中,所以WTCNT一定要給一個(gè)初始值.
Register Address R/W Description Reset Value
WTCNT 0x53000008 R/W Watchdog timer count register 0x8000
Bit Description Initial State
Count value [15:0] 定時(shí)器的當(dāng)前計(jì)數(shù)值 0x8000
我們先將watchdog的輸出重啟信號(hào)的開(kāi)關(guān)關(guān)掉,將中斷打開(kāi),把watchdog timer當(dāng)一個(gè)普通的定時(shí)器來(lái)用.設(shè)計(jì)如下:
- /*
- watchdogtimerwithdisablereset
- copyleft@dndxhej@gmail.com
- */
- .equNOINT,0xc0
- .equGPBCON,0x56000010@led
- .equGPBDAT,0x56000014@led
- .equGPBUP,0x56000018@led
- .equGPFCON,0x56000050@interruptconfig
- .equEINTMASK,0x560000a4
- .equEXTINT0,0x56000088
- .equEXTINT1,0x5600008c
- .equEXTINT2,0x56000090
- .equINTMSK,0x4A000008
- .equEINTPEND,0x560000a8
- .equSUBSRCPND,0x4a000018
- .equINTSUBMSK,0x4a00001c
- .equSRCPND,0X4A000000
- .equINTPND,0X4A000010
- .equGPB5_out,(1<<(5*2))
- .equGPB6_out,(1<<(6*2))
- .equGPB7_out,(1<<(7*2))
- .equGPB8_out,(1<<(8*2))
- .equGPBVALUE,(GPB5_out|GPB6_out|GPB7_out|GPB8_out)
- .equLOCKTIME,0x4c000000
- .equMPLLCON,0x4c000004
- .equUPLLCON,0x4c000008
- .equM_MDIV,92
- .equM_PDIV,1
- .equM_SDIV,1
- .equU_MDIV,56
- .equU_PDIV,2
- .equU_SDIV,2
- .equCLKDIVN,0x4c000014
- .equDIVN_UPLL,0
- .equHDIVN,1
- .equPDIVN,1@FCLK:HCLK:PCLK=1:2:4
- .equWTCON,0x53000000
- .equPre_scaler,249
- .equwd_timer,1
- .equclock_select,00@316
- .equint_gen,1@開(kāi)中斷
- .equreset_enable,0@關(guān)掉重啟信號(hào)
- .equWTDAT,0x53000004
- .equCount_reload,50000@定時(shí)器定為2SPCLK=100MPCLK/(Pre_scaler+1)/clock_select=100M/(249+1)/16=25k50000/25k=2s
- .equWTCNT,0x53000008
- .equCount,50000
- .global_start
- _start:breset
- ldrpc,_undefined_instruction
- ldrpc,_software_interrupt
- ldrpc,_prefetch_abort
- ldrpc,_data_abort
- ldrpc,_not_used
- @birq
- ldrpc,_irq
- ldrpc,_fiq
- _undefined_instruction:.wordundefined_instruction
- _software_interrupt:.wordsoftware_interrupt
- _prefetch_abort:.wordprefetch_abort
- _data_abort:.worddata_abort
- _not_used:.wordnot_used
- _irq:.wordirq
- _fiq:.wordfiq
- .balignl16,0xdeadbeef
- reset:
- ldrr3,=WTCON
- movr4,#0x0
- strr4,[r3]@disablewatchdog
- ldrr0,=GPBCON
- ldrr1,=0x15400
- strr1,[r0]
- ldrr2,=GPBDAT
- ldrr1,=0x160
- strr1,[r2]
- blclock_setup
- bldelay
-
相關(guān)推薦
技術(shù)專(zhuān)區(qū)
- FPGA
- DSP
- MCU
- 示波器
- 步進(jìn)電機(jī)
- Zigbee
- LabVIEW
- Arduino
- RFID
- NFC
- STM32
- Protel
- GPS
- MSP430
- Multisim
- 濾波器
- CAN總線(xiàn)
- 開(kāi)關(guān)電源
- 單片機(jī)
- PCB
- USB
- ARM
- CPLD
- 連接器
- MEMS
- CMOS
- MIPS
- EMC
- EDA
- ROM
- 陀螺儀
- VHDL
- 比較器
- Verilog
- 穩(wěn)壓電源
- RAM
- AVR
- 傳感器
- 可控硅
- IGBT
- 嵌入式開(kāi)發(fā)
- 逆變器
- Quartus
- RS-232
- Cyclone
- 電位器
- 電機(jī)控制
- 藍(lán)牙
- PLC
- PWM
- 汽車(chē)電子
- 轉(zhuǎn)換器
- 電源管理
- 信號(hào)放大器
評(píng)論