GNU ARM匯編--(八)s3c2440的watchdog
作者:
時間:2016-11-26
來源:網(wǎng)絡(luò)
收藏
msrcpsr_c,#0xd2@進(jìn)入中斷模式ldrsp,=3072@中斷模式的棧指針定義msrcpsr_c,#0xd3@進(jìn)入系統(tǒng)模式ldrsp,=4096@設(shè)置系統(tǒng)模式的棧指針@--------------------------------------------ldrr0,=GPBUPldrr1,=0x03f0strr1,[r0]ldrr0,=GPFCONldrr1,=0x2ea@0x2strr1,[r0]ldrr0,=EXTINT0@ldrr1,=0x8f888@0x0@0x8f888@~(7|(7<<4)|(7<<8)|(7<<16))//低電平觸發(fā)中斷ldrr1,=0xafaaa@0x0@0x8f888//下降沿觸發(fā)中斷strr1,[r0]ldrr0,=EINTPENDldrr1,=0xf0@0b10000strr1,[r0]ldrr0,=EINTMASKldrr1,=0x00@0b00000strr1,[r0]ldrr0,=SRCPNDldrr1,=0x3ff@0x1@0b11111strr1,[r0]ldrr0,=SUBSRCPNDldrr1,=0x1<<13strr1,[r0]ldrr0,=INTPNDldrr1,=0x3ff@0x1@0b11111strr1,[r0]ldrr0,=INTSUBMSKldrr1,=0x0<<13strr1,[r0]ldrr0,=INTMSKldrr1,=0xfffff000@0b00000strr1,[r0]MRSr1,cpsrBICr1,r1,#0x80MSRcpsr_c,r1blmainirq:sublr,lr,#4stmfdsp!,{r0-r12,lr}blirq_isrldmfdsp!,{r0-r12,pc}^irq_isr:ldrr2,=GPBDATldrr1,=0x0e0strr1,[r2]ldrr0,=EINTPENDldrr1,=0xf0strr1,[r0]ldrr0,=SRCPNDldrr1,=0x3ff@0b11111strr1,[r0]ldrr0,=SUBSRCPNDldrr1,=0x1<<13strr1,[r0]ldrr0,=INTPNDldrr1,=0x3ff@0b11111strr1,[r0]movpc,lrdelay:ldrr3,=0xffffffdelay1:subr3,r3,#1cmpr3,#0x0bnedelay1movpc,lrclock_setup:ldrr0,=LOCKTIMEldrr1,=0xffffffffstrr1,[r0]ldrr0,=CLKDIVNldrr1,=(DIVN_UPLL<<3)|(HDIVN<<1)|(PDIVN<<0)strr1,[r0]ldrr0,=UPLLCONldrr1,=(U_MDIV<<12)|(U_PDIV<<4)|(U_SDIV<<0)@Fin=12MUPLL=48Mstrr1,[r0]nopnopnopnopnopnopnopldrr0,=MPLLCONldrr1,=(M_MDIV<<12)|(M_PDIV<<4)|(M_SDIV<<0)@Fin=12MFCLK=400Mstrr1,[r0]movpc,lrmain:ldrr0,=WTDATldrr1,=Count_reloadstrr1,[r0]ldrr0,=WTCNTldrr1,=Countstrr1,[r0]ldrr0,=WTCONldrr1,=(Pre_scaler<<8)|(wd_timer<<5)|(clock_select<<3)|(int_gen<<2)|(reset_enable)strr1,[r0]ledloop:ldrr1,=0x1c0strr1,[r2]bldelayldrr1,=0x1a0strr1,[r2]bldelayldrr1,=0x160strr1,[r2]bldelayldrr1,=0x0e0strr1,[r2]bldelaybledloopundefined_instruction:nopsoftware_interrupt:nopprefetch_abort:nopdata_abort:nopnot_used:nopfiq:nop
程序?qū)崿F(xiàn)的是:一個正常的流水燈,定時器每隔2s觸發(fā)一次中斷,中斷處理中點(diǎn)亮第四個LED.本文引用地址:http://butianyuan.cn/article/201611/321723.htm 稍微該一下上面的代碼:
.equ int_gen, 0 @關(guān)中斷
.equ reset_enable, 1 @打開重啟信號
打開重啟信號,則可以看到每隔2s系統(tǒng)就重啟一次.
如果在循環(huán)中加入:
ldr r0, =WTCNT @喂狗
ldr r1, =Count
str r1, [r0]
那么,這又是一個標(biāo)準(zhǔn)的流水燈了.而且是有watchdog保護(hù)的流水燈了.
評論