📄 cpuini.asm
字号:
;定义CS8900的内部寄存器
;及其相应的控制字
;使用I/O方式
freerun .set 0
cpu2407a .set 1
baseethernet .set 0000h
.mmregs
; .include "f2407regs.asm"
.ref _wdkey
.ref _wdcr
.ref _wdcntr
.ref wsgr
.ref _scsr1
.ref _scsr2
.ref _xint1cr
.ref _xint2cr
.ref _gptcona
.ref _t1con
.ref _t2con
.ref _evaifra
.ref _evaifrb
.ref _evaifrc
.ref _evaimra
.ref _evaimrb
.ref _evaimrc
.ref _comcona
.ref _capcona
.ref _t1pr
.ref _t2pr
.ref _t1cnt
.ref _t2cnt
.ref _gptconb
.ref _t3con
.ref _t4con
.ref _evbifra
.ref _evbifrb
.ref _evbifrc
.ref _evbimra
.ref _evbimrb
.ref _evbimrc
.ref _comconb
.ref _capconb
.ref _t3pr
.ref _t4pr
.ref _t3cnt
.ref _t4cnt
.ref _sciccr
.ref _scictl1
.ref _scictl2
.ref _scihbaud
.ref _scilbaud
.ref _scipri
.ref _adcctrl1
.ref _adcctrl2
.ref _mcra
.ref _mcrb
.ref _mcrc
.ref _padatdir
.ref _pbdatdir
.ref _pcdatdir
.ref _pddatdir
.ref _pedatdir
.ref _pfdatdir
.def _bakport
.def _bakporta
.def _bakportb
.def _bakportc
.def _bakportd
.def _bakporte
.def _bakportf
.def _bakled
.def _ledtime
.def _freeuse0
.def _freeuse1
.def _freeuse2
.def _freeuse3
cinterrupt .set 00000h
ciobaseadd .set 00300h
cdmachannel .set 00003h
_bakport .usect ".bakport",32,1
_bakporta .set _bakport+0
_bakportb .set _bakport+1
_bakportc .set _bakport+2
_bakportd .set _bakport+3
_bakporte .set _bakport+4
_bakportf .set _bakport+5
_bakled .set _bakport+6
_ledtime .set _bakport+7
_freeuse0 .set _bakport+16
_freeuse1 .set _bakport+17
_freeuse2 .set _bakport+18
_freeuse3 .set _bakport+19
.ref _padatdir
.ref _pbdatdir
.ref _pcdatdir
.ref _pddatdir
.ref _pedatdir
.ref _pfdatdir
.ref _OSCtxSw
.ref _OSTickISR
.ref _c_int0
.def _sysinit
; .include "f2407regs.asm" ;引用头部文件
.ref _c_int0
.ref _OSTickISR
.ref _OSCtxSw
;(1)建立中断向量表
.sect ".vectors" ;定义主向量段
rsvect: b _c_int0;PM 0 复位向量 1
int1: b phantom;PM 2 中断优先级1 4
int2: b _OSTickISR;PM 4 中断优先级2 5
int3: b phantom;PM 6中断优先级3 6
int4: b phantom;PM 8 中断优先级4 7
int5: b phantom;PM A 中断优先级5 8
int6: b phantom;PM C 中断优先级6 9
RESERVED: b phantom;PM E (保留位) 10
sw_int8: b _OSCtxSw;PM 10 用户定义软件中断 -
sw_int9: b phantom;PM 12
sw_int10: b phantom;PM 14
sw_int11: b phantom;PM 16
sw_int12: b phantom;PM 18
sw_int13: b phantom;PM 1a
sw_int14: b phantom;PM 1c
sw_int15: b phantom;PM 1e
sw_int16: b phantom;PM 20
sw_int17: b phantom;PM 22
sw_int18: b phantom;PM 24
sw_int19: b phantom;PM 26
sw_int20: b phantom;PM 28
sw_int21: b phantom;PM 2a
sw_int22: b phantom;PM 2c
sw_int23: b phantom;PM 2e
sw_int24: b phantom;PM 30
sw_int25: b phantom;PM 32
sw_int26: b phantom;PM 34
sw_int27: b phantom;PM 36
sw_int28: b phantom;PM 38
sw_int29: b phantom;PM 3a
sw_int30: b phantom;PM 3c
sw_int31: b phantom;PM 3e 用户定义软件中断 -
.word 0ffffh;40h
.word 0ffffh;41h
.word 0ffffh;42h
.word 0ffffh;43h
;中断子向量入口定义pvecs
.sect ".pvecs";定义子向量段
pvectors:
b phantom ;保留向量地址偏移量0000h;44h
b xint1_isr ;保留向量地址偏移量0001h;46h
b phantom ;保留向量地址偏移量0002h;48h
b phantom ;保留向量地址偏移量0003h;4ah
b adcint_isr ;保留向量地址偏移量0004h;4ch
b spi_isr ;保留向量地址偏移量0005h;4eh
b sci_rx_isr ;保留向量地址偏移量0006h SCI接收中断;50h
b sci_tx_isr ;保留向量地址偏移量0007h;52h
b phantom ;保留向量地址偏移量0008h;54h
b phantom ;保留向量地址偏移量0009h;56h
b phantom ;保留向量地址偏移量000ah;58h
b phantom ;保留向量地址偏移量000bh;5ah
b phantom ;保留向量地址偏移量000ch;5ch
b phantom ;保留向量地址偏移量000dh;5e
b phantom ;保留向量地址偏移量000eh;60
b phantom ;保留向量地址偏移量000fh;62
b phantom ;保留向量地址偏移量0010h;64
b xint2_isr ;保留向量地址偏移量0011h;66
b phantom ;保留向量地址偏移量0012h;68
b phantom ;保留向量地址偏移量0013h;6a
b phantom ;保留向量地址偏移量0014h;6c
b phantom ;保留向量地址偏移量0015h;6e
b phantom ;保留向量地址偏移量0016h;70
b phantom ;保留向量地址偏移量0017h;72
b phantom ;保留向量地址偏移量0018h;74
b pdpintb_isr ;保留向量地址偏移量0019h;76
b phantom ;保留向量地址偏移量001ah;78
b phantom ;保留向量地址偏移量001bh;7a
b phantom ;保留向量地址偏移量001ch;7c
b phantom ;保留向量地址偏移量001dh;7e
b phantom ;保留向量地址偏移量001eh;80
b phantom ;保留向量地址偏移量001fh;82
b pdpinta_isr ;保留向量地址偏移量0020h;84
b cmp1int_isr ;保留向量地址偏移量0021h;86
b cmp2int_isr ;保留向量地址偏移量0022h;88
b cmp3int_isr ;保留向量地址偏移量0023h;8a
b cmp4int_isr ;保留向量地址偏移量0024h;8c
b cmp5int_isr ;保留向量地址偏移量0025h;8e
b cmp6int_isr ;保留向量地址偏移量0026h;90
b t1pint_isr ;保留向量地址偏移量0027h;92
b t1cint_isr ;保留向量地址偏移量0028h;94
b t1ufint_isr ;保留向量地址偏移量0029h;96
b t1ofint_isr ;保留向量地址偏移量002ah;98
b t2pint_isr ;保留向量地址偏移量002bh;9a
b t2cint_isr ;保留向量地址偏移量002ch;9c
b t2ufint_isr ;保留向量地址偏移量002dh;9e
b t2ofint_isr ;保留向量地址偏移量002eh;a0
b t3pint_isr ;保留向量地址偏移量002fh;a2
b t3cint_isr ;保留向量地址偏移量0030h;a4
b t3ufint_isr ;保留向量地址偏移量0031h;a6
b t3ofint_isr ;保留向量地址偏移量0032h;a8
b cap1int_isr ;保留向量地址偏移量0033h;aa
b cap2int_isr ;保留向量地址偏移量0034h;ac
b cap3int_isr ;保留向量地址偏移量0035h;ae
b cap4int_isr ;保留向量地址偏移量0036h;b0
b cap5int_isr ;保留向量地址偏移量0037h;b2
b cap6int_isr ;保留向量地址偏移量0038h;b4
b t4pint_isr ;保留向量地址偏移量0039h;b6
b t4cint_isr ;保留向量地址偏移量003ah;b8
b t4ufint_isr ;保留向量地址偏移量003bh;ba
b t4ofint_isr ;保留向量地址偏移量003ch;bc
b phantom ;保留向量地址偏移量003dh;be
b phantom ;保留向量地址偏移量003eh;c0
b phantom ;保留向量地址偏移量003fh;c2
b canmbint_isr ;保留向量地址偏移量0040h;c4
b canerint_isr ;保留向量地址偏移量0041h;c6
.word 0ef00h;c8h
.word 0ef00h;c9h
.word 0ef00h;cah
.word 0ef00h;cbh
.word 0ef00h;cch
.word 0ef00h;cdh
.word 0ef00h;ceh
.word 0ef00h;cfh
.word 0ef00h;d0h
.word 0ef00h;d1h
.word 0ef00h;d2h
.word 0ef00h;d3h
.word 0ef00h;d4h
.word 0ef00h;d5h
.word 0ef00h;d6h
.word 0ef00h;d7h
.word 0ef00h;d8h
.word 0ef00h;d9h
.word 0ef00h;dah
.word 0ef00h;dbh
.word 0ef00h;dch
.word 0ef00h;ddh
.word 0ef00h;deh
.word 0ef00h;dfh
.word 0ef00h;e0h
.word 0ef00h;e1h
.word 0ef00h;e2h
.word 0ef00h;e3h
.word 0ef00h;e4h
.word 0ef00h;e5h
.word 0ef00h;e6h
.word 0ef00h;e7h
.word 0ef00h;e8h
.word 0ef00h;e9h
.word 0ef00h;eah
.word 0ef00h;ebh
.word 0ef00h;ech
.word 0ef00h;edh
.word 0ef00h;eeh
.word 0ef00h;efh
.word 0ef00h;f0h
.word 0ef00h;f1h
.word 0ef00h;f2h
.word 0ef00h;f3h
.word 0ef00h;f4h
.word 0ef00h;f5h
.word 0ef00h;f6h
.word 0ef00h;f7h
.word 0ef00h;f8h
.word 0ef00h;f9h
.word 0ef00h;fah
.word 0ef00h;fbh
.word 0ef00h;fch
.word 0ef00h;fdh
.word 0ef00h;feh
.word 0ef00h;ffh
kick_dog .macro ;Watchdog reset macro
ldp #00e0h
splk #05555h,_wdkey
splk #0aaaah,_wdkey
ldp #0h
.endm
;(2)主程序
.def _sysinit
.text
_sysinit:
;don't need save register
;because the T,ACC,PREG and
;ar0-ar7 not use
;and the change of st0,st1
;wsgr,scsr1,scsr2,wdcr are need
setc intm
clrc sxm
clrc ovm
clrc cnf ;B0 被配置为数据存储空间
ldpk _freeuse0
splk #080h,_freeuse0
out _freeuse0,wsgr
ldp #0
splk #0ffffh,ifr;清全部中断标志
ldpk #_scsr1;/128
splk #0c24fh,_scsr1
;CLKIN=10M,
;CPUCLK=20M,
;CLKOUT=20M/512
;是否使能EVB CLK?
.if (freerun==0)
.if (cpu2407a==1)
splk #01001110b,_scsr2
.else
splk #00001110b,_scsr2
.endif
.else;(freerun==1)
.if (cpu2407a==1)
splk #01001010b,_scsr2
.else
splk #00001010b,_scsr2
.endif
.endif;freerun
ldp #_wdcr;/128
;splk #0afh,_wdcr ;使能WDT
splk #0efh,_wdcr ;disable WDT
splk #256-244,_wdcntr
;64 prescale
;wdclk=20M/512/64=2441
;100ms delay is 244
kick_dog
; ;the code behind can be changed by user
; ldpk _bakled
; splk #0,_bakled
; splk #4,_ledtime
; lar ar1,#800h
; ;the code front can be changed by user
ret
xint1_isr:ret
adcint_isr:ret
spi_isr:ret
sci_rx_isr:ret
sci_tx_isr:ret
xint2_isr:ret
pdpintb_isr:ret
pdpinta_isr:ret
cmp1int_isr:ret
cmp2int_isr:ret
cmp3int_isr:ret
cmp4int_isr:ret
cmp5int_isr:ret
cmp6int_isr:ret
t1pint_isr:ret
t1cint_isr:ret
t1ufint_isr:ret
t1ofint_isr:ret
t2pint_isr:ret
t2cint_isr:ret
t2ufint_isr:ret
t2ofint_isr:ret
t3pint_isr:ret
t3cint_isr:ret
t3ufint_isr:ret
t3ofint_isr:ret
cap1int_isr:ret
cap2int_isr:ret
cap3int_isr:ret
cap4int_isr:ret
cap5int_isr:ret
cap6int_isr:ret
t4pint_isr:ret
t4cint_isr:ret
t4ufint_isr:ret
t4ofint_isr:ret
canmbint_isr:ret
canerint_isr:
ret
phantom:
kick_dog
ret
.def _intinitial
_intinitial:
POPD *+ ;return address(PC)
SAR AR0,*+ ;frame point(FP)
SAR AR1,* ;temp variable
;temp variable no use
LARK AR0,1 ;temp variable's num is one
LAR AR0,*0+ ;
; <save register vars>
sar ar2,*+ ;ar2
;saved in the stack
;is PC,FP(ar0),
;temp variable(1) and
;ar2
;mar *,ar?
; code for the function
ldp #0
splk #0ffffh,ifr;清全部中断标志
;操作系统用INT2的T1PINT
; 作定时器
ldp #_xint1cr;/128
splk #8005h,_xint1cr
;xint1 high priority
splk #8007h,_xint2cr
;xint2 low priority
ldp #_gptcona;/128
splk #0001011101000000b,_t1con
splk #0001011101000000b,_t2con
;splk #0101010001000000b,_t2con
splk #0000000000000000b,_gptcona
splk #0000011111111111b,_evaifra
splk #0000000000001111b,_evaifrb
splk #0000000000000111b,_evaifrc
splk #0000000010000000b,_evaimra
;enable t1pint
splk #0000000000000000b,_evaimrb
splk #0000000000000000b,_evaimrc
splk #0,_comcona
splk #0010011001010100b,_capcona
splk #1561,_t1pr
splk #1561,_t2pr;100hz,#19530,t2pr
splk #0,_t1cnt
splk #0,_t2cnt
ldp #_gptconb;/128
splk #0101010000000000b,_t3con
splk #0101010000000000b,_t4con
splk #0000000000000000b,_gptconb
splk #0000011111111111b,_evbifra
splk #0000000000001111b,_evbifrb
splk #0000000000000111b,_evbifrc
splk #0000000000000000b,_evbimra
splk #0000000000000000b,_evbimrb
splk #0000000000000000b,_evbimrc
splk #0,_comconb
splk #0000011000000100b,_capconb
;splk #0001011000000100b,_capconb
;splk #0000001000000000b,_capconb
ldp #_sciccr;/128
splk #67h,_sciccr
splk #03h,_scictl1
splk #00h,_scictl2
splk #01h,_scihbaud
splk #03h,_scilbaud;9600
splk #23h,_scictl1
splk #01111000b,_scipri
ldp #_adcctrl1;/128
splk #0101011111000000b,_adcctrl1
splk #0000001000000010b,_adcctrl2
splk #0000000000010111b,_mcra
splk #1111111100000000b,_mcrb
splk #0000000000000000b,_mcrc
lar ar2,#_bakporta
mar *,ar2
lacc #1100000011000000b
sacl _padatdir
sacl *+
lacc #1000111100000000b
sacl _pbdatdir
sacl *+
lacc #1100000011000000b
sacl _pcdatdir
sacl *+
lacc #0000000000000000b
sacl _pddatdir
sacl *+
lacc #1001111110001011b
sacl _pedatdir
sacl *+
lacc #0000000000000000b
sacl _pfdatdir
sacl *+
ldp #0
splk #0ffffh,ifr;清全部中断标志
splk #0002h,imr ;不使能
eint ;enable interrupts
MAR *,AR1
; <restore register vars>
MAR *-
lar ar2,* ;if need
;NOTICE the last is *
; not *-
; the next instruction use
; mmm+1.You may use
; lar ar?,*-
; sbrk ar0,1
; to replace it
SBRK 1+1
LAR AR0,*-
PSHD *
RET
;_intinitial end
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -