GNU ARM汇编--(八)s3c2440的watchdog
时间:11-26
来源:互联网
点击:
- e,0@关掉重启信号
- .equWTDAT,0x53000004
- .equCount_reload,50000@定时器定为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
- msrcpsr_c,#0xd2@进入中断模式
- ldrsp,=3072@中断模式的栈指针定义
- msrcpsr_c,#0xd3@进入系统模式
- ldrsp,=4096@设置系统模式的栈指针
- @--------------------------------------------
- ldrr0,=GPBUP
- ldrr1,=0x03f0
- strr1,[r0]
- ldrr0,=GPFCON
- ldrr1,=0x2ea@0x2
- strr1,[r0]
- ldrr0,=EXTINT0
- @ldrr1,=0x8f888@0x0@0x8f888@~(7|(7<4)|(7<8)|(7<16))//低电平触发中断
- ldrr1,=0xafaaa@0x0@0x8f888//下降沿触发中断
- strr1,[r0]
- ldrr0,=EINTPEND
- ldrr1,=0xf0@0b10000
- strr1,[r0]
- ldrr0,=EINTMASK
- ldrr1,=0x00@0b00000
- strr1,[r0]
- ldrr0,=SRCPND
- ldrr1,=0x3ff@0x1@0b11111
- strr1,[r0]
- ldrr0,=SUBSRCPND
- ldrr1,=0x1<13
- strr1,[r0]
- ldrr0,=INTPND
- ldrr1,=0x3ff@0x1@0b11111
- strr1,[r0]
- ldrr0,=INTSUBMSK
- ldrr1,=0x0<13
- strr1,[r0]
- ldrr0,=INTMSK
- ldrr1,=0xfffff000@0b00000
- strr1,[r0]
- MRSr1,cpsr
- BICr1,r1,#0x80
- MSRcpsr_c,r1
- blmain
- irq:
- sublr,lr,#4
- stmfdsp!,{r0-r12,lr}
- blirq_isr
- ldmfdsp!,{r0-r12,pc}^
- irq_isr:
- ldrr2,=GPBDAT
- ldrr1,=0x0e0
- strr1,[r2]
- ldrr0,=EINTPEND
- ldrr1,=0xf0
- strr1,[r0]
- ldrr0,=SRCPND
- ldrr1,=0x3ff@0b11111
- strr1,[r0]
- ldrr0,=SUBSRCPND
- ldrr1,=0x1<13
- strr1,[r0]
- ldrr0,=INTPND
- ldrr1,=0x3ff@0b11111
- strr1,[r0]
- movpc,lr
- delay:
- ldrr3,=0xffffff
- delay1:
- subr3,r3,#1
- cmpr3,#0x0
- bnedelay1
- movpc,lr
- clock_setup:
- ldrr0,=LOCKTIME
- ldrr1,=0xffffffff
- strr1,[r0]
- ldrr0,=CLKdivN
- ldrr1,=(divN_UPLL<3)|(HdivN<1)|(PdivN<0)
- strr1,[r0]
- ldrr0,=UPLLCON
- ldrr1,=(U_Mdiv<12)|(U_Pdiv<4)|(U_Sdiv<0)@Fin=12MUPLL=48M
- strr1,[r0]
- nop
- nop
- nop
- nop
- nop
- nop
- nop
- ldrr0,=MPLLCON
- ldrr1,=(M_Mdiv<12)|(M_Pdiv<4)|(M_Sdiv<0)@Fin=12MFCLK=400M
- strr1,[r0]
- movpc,lr
- main:
- ldrr0,=WTDAT
- ldrr1,=Count_reload
- strr1,[r0]
- ldrr0,=WTCNT
- ldrr1,=Count
- strr1,[r0]
- ldrr0,=WTCON
- ldrr1,=(Pre_scaler<8)|(wd_timer<5)|(clock_select<3)|(int_gen<2)|(reset_enable)
- strr1,[r0]
- ledloop:
- ldrr1,=0x1c0
- strr1,[r2]
- bldelay
- ldrr1,=0x1a0
- strr1,[r2]
- bldelay
- ldrr1,=0x160
- strr1,[r2]
- bldelay
- ldrr1,=0x0e0
- strr1,[r2]
- bldelay
- bledloop
- undefined_instruction:
- nop
- software_interrupt:
- nop
- prefetch_abort:
- nop
- data_abort:
- nop
- not_used:
- nop
- fiq:
- nop
程序实现的是:一个正常的流水灯,定时器每隔2s触发一次中断,中断处理中点亮第四个LED.
稍微该一下上面的代码:
.equ int_gen, 0 @关中断
.equ reset_enable, 1 @打开重启信号
打开重启信号,则可以看到每隔2s系统就重启一次.
如果在循环中加入:
ldr r0, =WTCNT @喂狗
ldr r1, =Count
str r1, [r0]
那么,这又是一个标准的流水灯了.而且是有watchdog保护的流水灯了.
ARM汇编s3c2440watchdo 相关文章:
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)