程序如下
.include"DSP28_REG.asm"
.def T1PINT_ISR
.def T2PINT_ISR
.def T3PINT_ISR
.def T4PINT_ISR
.global start
start:
LC InitSysCtrl
DINT
AND IER,#0x0000
AND IFR,#0x0000
LC InitPieCtrl
LC InitPieVectTable
LC Init_eva_timer1
LC Init_eva_timer2
LC Init_eva_timer3
LC Init_eva_timer4
MOVL XAR0,#PIEIER2
OR *XAR0,#0x0008
MOVL XAR0,#PIEIER3
OR *XAR0,#0x0001
MOVL XAR0,#PIEIER4
OR *XAR0,#0x0008
MOVL XAR0,#PIEIER5
OR *XAR0,#0x0001
OR IER,#0x001E
EINT
CLRC DBGM
mainloop:
NOP
NOP
NOP
NOP
LB mainloop
;***************************************
InitSysCtrl:
EALLOW
;????
MOVL XAR0,#WDCR
OR *XAR0,#0x0068
MOVL XAR0,#PLLCR
MOV *XAR0,#0x000A
LC DELAY_10mS
MOVL XAR0,#HISPCP
MOV *XAR0,#0x0001
MOVL XAR0,#LOSPCP
MOV *XAR0,#0x0002
MOVL XAR0,#PCLKCR
OR *XAR0,#0x0008
EDIS
LRET
;*****************************************
InitPieCtrl:
MOVL XAR0,#PIECTRL
OR *XAR0,#0x0000
MOVL XAR0,#PIEIER1
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER2
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER3
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER4
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER5
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER6
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER7
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER8
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER9
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER10
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER11
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIER12
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR1
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR2
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR3
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR4
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR5
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR6
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR7
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR8
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR9
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR10
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR11
MOV *XAR0,#0x0000
MOVL XAR0,#PIEIFR12
MOV *XAR0,#0x0000
MOVL XAR0,#PIECTRL
OR *XAR0,#0x0001
MOVL XAR0,#PIEACK
MOV *XAR0,#0xFFFF
LRET
;********************************************
InitPieVectTable:
NOP
EALLOW
NOP
MOVL XAR0,#T1PINT_ISR
MOVL XAR1,#0x0D56
MOVL *XAR1,XAR0
MOVL XAR0,#T2PINT_ISR
MOVL XAR1,#0x0D60
MOVL *XAR1,XAR0
MOVL XAR0,#T3PINT_ISR
MOVL XAR1,#0x0D76
MOVL *XAR1,XAR0
MOVL XAR0,#T4PINT_ISR
MOVL XAR1,#0x0D80
MOVL *XAR1,XAR0
NOP
EDIS
NOP
LRET
;*****************Timer1/2/3/4初始化****************************
Init_eva_timer1:
MOVL XAR0,#GPTCONA
MOV *XAR0,#0x0000
MOVL XAR0,#T1PR
MOV *XAR0,#0x0200
MOVL XAR0,#T1CMPR
MOV *XAR0,#0x0000
MOVL XAR0,#EVAIMRA
OR *XAR0,#0x0080
MOVL XAR0,#EVAIFRA
OR *XAR0,#0x0080
MOVL XAR0,#T1CNT
MOV *XAR0,#0x0000
MOVL XAR0,#T1CON
MOV *XAR0,#0x1742
MOVL XAR0,#GPTCONA
OR *XAR0,#0x0100
LRET
Init_eva_timer2:
MOVL XAR0,#GPTCONA
MOV *XAR0,#0x0000
MOVL XAR0,#T2PR
MOV *XAR0,#0x0400
MOVL XAR0,#T2CMPR
MOV *XAR0,#0x0000
MOVL XAR0,#EVAIMRB
OR *XAR0,#0x0001
MOVL XAR0,#EVAIFRB
OR *XAR0,#0x0001
MOVL XAR0,#T2CNT
MOV *XAR0,#0x0000
MOVL XAR0,#T2CON
MOV *XAR0,#0x1742
MOVL XAR0,#GPTCONA
OR *XAR0,#0x0400
LRET
Init_eva_timer3:
MOVL XAR0,#GPTCONB
MOV *XAR0,#0x0000
MOVL XAR0,#T3PR
MOV *XAR0,#0x0800
MOVL XAR0,#T3CMPR
MOV *XAR0,#0x0000
MOVL XAR0,#EVBIMRA
OR *XAR0,#0x0080
MOVL XAR0,#EVBIFRA
OR *XAR0,#0x0080
MOVL XAR0,#T3CNT
MOV *XAR0,#0x0000
MOVL XAR0,#T3CON
MOV *XAR0,#0x1742
MOVL XAR0,#GPTCONB
OR *XAR0,#0x0100
LRET
Init_eva_timer4:
MOVL XAR0,#GPTCONB
MOV *XAR0,#0x0000
MOVL XAR0,#T4PR
MOV *XAR0,#0x1000
MOVL XAR0,#T4CMPR
MOV *XAR0,#0x0000
MOVL XAR0,#EVBIMRB
OR *XAR0,#0x0001
MOVL XAR0,#EVBIFRB
OR *XAR0,#0x0001
MOVL XAR0,#T4CNT
MOV *XAR0,#0x0000
MOVL XAR0,#T4CON
MOV *XAR0,#0x1742
MOVL XAR0,#GPTCONB
OR *XAR0,#0x0400
LRET
;***********************************************************
DELAY_10mS: NOP
MOV AR0,#60000 ;10ms/7.41ns=1499250=60000*22
$0: RPT #17 ;1
|| NOP ;1*3
BANZ $0,AR0-- ;4
NOP
LRET
;************************************************************
T1PINT_ISR:
MOVL XAR0,#EVAIMRA
OR *XAR0,#0x0080
MOVL XAR0,#EVAIFRA
OR *XAR0,#0x0080
MOVL XAR0,#PIEACK
OR *XAR0,#0x0002
IRET
T2PINT_ISR:
MOVL XAR0,#EVAIMRB
OR *XAR0,#0x0001
MOVL XAR0,#EVAIFRB
OR *XAR0,#0x0001
MOVL XAR0,#PIEACK
OR *XAR0,#0x0004
IRET
T3PINT_ISR:
MOVL XAR0,#EVBIFRA
OR *XAR0,#0x0080
MOVL XAR0,#PIEACK
OR *XAR0,#0x0008
IRET
T4PINT_ISR:
MOVL XAR0,#EVBIFRB
OR *XAR0,#0x0001
MOVL XAR0,#PIEACK
OR *XAR0,#0x0010
IRET
.end
这程序真不短。。。
一周热门 更多>