📄 exer3.asm
字号:
.title "for test INT service program ...(25 us) "
.mmregs
.global _c_int00,_tint,vector
OFF_INTIMER .set 04Ch ; vector of INTtimer at VECTOR+OFF_INTIMER
INIT_A .set 079bch ; A/2=0.9510498
INIT_B .set 0c000h ; B/2=-0.5
INIT_C .set 013c7h ; C/2=0.1545105
;count .set 0
.bss y0,1
.bss y1,1
.bss y2,1
.bss temp,1
.bss AA,1
.bss BB,1
.bss CC,1
.bss buf,128
.bss count,1
.text
_c_int00:
ld #0,dp
ssbx intm ; disable all interrupt !
ld #vector, a ; get vector table address !
and #0FF80h, a
andm #007Fh, pmst
or pmst, a
stlm a, pmst ; 设置IPTR
stm #10h,TCR ; init TIMER
stm #2499,PRD ; f=100M/(2499+1)=40kHz
stm #20h,TCR ; reset TIMER
ldm IMR,a ; read back IMR
or #08h,a ; enable TIMER interrupt
stlm a,IMR ; set IMR
ld #temp,dp ; set DP
ssbx FRCT ; prepare for fraction mpy
st #INIT_A,AA ; init AA,BB,CC
st #INIT_B,BB ;
st #INIT_C,CC ;
pshd CC
popd y2 ; init y2,y2=CC
ld AA,T ; T=AA
mpy y2,a ; y2*AA -> a
sth a,y1 ; y2*AA -> y1
stm #0h,TCR ; enable TIMER
stm #count,ar2
st #1,*ar2
STM #buf,ar1
nop
rsbx intm ; enable all int !
again:
nop
b again
nop
nop
nop
nop
nop
nop
;-------------------------------------------------------------
; interrupt for INT_TIMER !
;-------------------------------------------------------------
_tint:
ld #BB,DP
;
ld BB,T ; T=BB
mpy y2,a ; a=y2*BB
ltd y1 ; T=y1,y2=y1
mac AA,a ; a=a+y1*AA
sth a,1,y1 ; new cos data -> y1
sth a,y0 ; new cos data -> y0
ld y0,B
; st count,ar3
; ld ar3,ar0
; ld *ar2,T
stl B,*ar1+
stm count,ar2
ld *ar2,a
add #1,a
stl a,*ar2
cmpm *ar2,#127
bc loop,ntc
stm #count,ar2
st #0,*ar2
stm #87h,ar1
loop:
; stm count,a
nop ; set breakpoint in CCS !!!
int1_end:
nop
rete
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -