下面是我写的流水灯程序,但是好像出问题了,只能闪一轮,然后就不能闪;了,望大神指点
stm8/
#include "stm8s105c6.inc"
#include "user_register.inc"
#include "mapping.inc"
segment 'rom'
main.l
; initialize SP
ldw X,#stack_end
ldw SP,X
#ifdef RAM0
; clear RAM0
ram0_start.b EQU $ram0_segment_start
ram0_end.b EQU $ram0_segment_end
ldw X,#ram0_start
clear_ram0.l
clr (X)
incw X
cpw X,#ram0_end
jrule clear_ram0
#endif
#ifdef RAM1
; clear RAM1
ram1_start.w EQU $ram1_segment_start
ram1_end.w EQU $ram1_segment_end
ldw X,#ram1_start
clear_ram1.l
clr (X)
incw X
cpw X,#ram1_end
jrule clear_ram1
#endif
; clear stack
stack_start.w EQU $stack_segment_start
stack_end.w EQU $stack_segment_end
ldw X,#stack_start
clear_stack.l
clr (X)
incw X
cpw X,#stack_end
jrule clear_stack
;初始化IO引脚
MOV PB_DDR,#$FF
MOV PB_CR1,#$00
MOV PB_ODR,#$FF
;初始化时钟
MOV R01,#$FE
SCF
MOV R10,#50
MOV CLK_SWR,#$E1
MOV CLK_CKDIVR,#$18
BRES CLK_ICKR,#5
MOV CLK_PCKENR1,#$FF
;初始化定时器
MOV TIM1_SMCR,#$00
BRES TIM1_ETR,#6
MOV TIM1_PSCRH,#$00
MOV TIM1_PSCRL,#$01
MOV TIM1_ARRH,#$27
MOV TIM1_ARRL,#$10
MOV TIM1_CR1,#$04
BSET TIM1_EGR,#0
BSET TIM1_IER,#0
BSET TIM1_CR1,#0
;初始化中断优先级
BRES ITC_SPR3,#7
BRES ITC_SPR3,#6
RIM
loop.L
jpf loop
;中断程序
interrupt TIM1
TIM1.L
BRES TIM1_SR1,#0
DEC R10
JRNE TIM1_EXIT
MOV R10,#50
MOV PB_ODR,R01
RLC R01
TIM1_EXIT.L
IRET
IRET
IRET
IRET
IRET
interrupt NonHandledInterrupt
NonHandledInterrupt.l
iret
segment 'vectit'
dc.l {$82000000+main} ; reset
dc.l {$82000000+NonHandledInterrupt} ; trap
dc.l {$82000000+NonHandledInterrupt} ; irq0
dc.l {$82000000+NonHandledInterrupt} ; irq1
dc.l {$82000000+NonHandledInterrupt} ; irq2
dc.l {$82000000+NonHandledInterrupt} ; irq3
dc.l {$82000000+NonHandledInterrupt} ; irq4
dc.l {$82000000+NonHandledInterrupt} ; irq5
dc.l {$82000000+NonHandledInterrupt} ; irq6
dc.l {$82000000+NonHandledInterrupt} ; irq7
dc.l {$82000000+NonHandledInterrupt} ; irq8
dc.l {$82000000+NonHandledInterrupt} ; irq9
dc.l {$82000000+NonHandledInterrupt} ; irq10
dc.l {$82000000+TIM1} ; irq11
dc.l {$82000000+NonHandledInterrupt} ; irq12
dc.l {$82000000+NonHandledInterrupt} ; irq13
dc.l {$82000000+NonHandledInterrupt} ; irq14
dc.l {$82000000+NonHandledInterrupt} ; irq15
dc.l {$82000000+NonHandledInterrupt} ; irq16
dc.l {$82000000+NonHandledInterrupt} ; irq17
dc.l {$82000000+NonHandledInterrupt} ; irq18
dc.l {$82000000+NonHandledInterrupt} ; irq19
dc.l {$82000000+NonHandledInterrupt} ; irq20
dc.l {$82000000+NonHandledInterrupt} ; irq21
dc.l {$82000000+NonHandledInterrupt} ; irq22
dc.l {$82000000+NonHandledInterrupt} ; irq23
dc.l {$82000000+NonHandledInterrupt} ; irq24
dc.l {$82000000+NonHandledInterrupt} ; irq25
dc.l {$82000000+NonHandledInterrupt} ; irq26
dc.l {$82000000+NonHandledInterrupt} ; irq27
dc.l {$82000000+NonHandledInterrupt} ; irq28
dc.l {$82000000+NonHandledInterrupt} ; irq29
end
|