📄 time.asm
字号:
********************************************************************************
* MEMORY.ASM v1.00 *
* 版权(c) 2003- 北京合众达电子技术有限责任公司 *
* 设计者: 段立锋 *
*********************************************************************************
.file "time.asm"
.c_mode
.mmregs
.copy "vc54x.inc" ; VC5402 Memory-Mapped Register Declaration
.copy "dec5416.inc" ; SEED DEC5416 Memory-Mapped Register Declaration
.def _boot_end
.ref _time_state
.def _time_isr
.def _time_start
.def _led_on
****************************************************************************
*定时器设置参数 *
****************************************************************************
PRD_DATA .set 0ffffH ;the period of timer is 0.001s
TCR_START .set 0fcfH ;start the timer
.text
*********************************************************************************
* *
* 函数定义:void _led_on() *
* 功 能:;启动定时器 *
* *
* 入口参数: 无 *
* 出口参数: 无 *
* 资源使用:无 *
* *
*********************************************************************************
_led_on: STM #_time_state,AR0
LD *AR0(1),A
STM #0,AH
AND #01,A
BC turn_on,AEQ
RSBX XF
B led_exit
turn_on: SSBX XF
led_exit: .if __far_mode
FRET
.else
RET
.endif
*********************************************************************************
* *
* 函数定义:void _time_start() *
* 功 能:;启动定时器 *
* *
* 入口参数: 无 *
* 出口参数: 无 *
* 资源使用:无 *
* *
*********************************************************************************
_time_start: STM #PRD_DATA,PRD ;set the period of the Timer0
STM #PRD_DATA,TIM
STM #TCR_START,TCR ;start the timer
.if __far_mode
FRET
.else
RET
.endif
****************************************************************************
*定时器中断服务程序,频率为38Hz *
****************************************************************************
_time_isr: PSHM AL
PSHM AH
PSHM AR0
STM #_time_state,AR0
;取当前的高电平计数值
LD *AR0(0),A
;计数值减一
STM #0,AH
BC reload,AEQ
SUB #1,A
STL A,*AR0(0)
B time_next
reload: STM #20h,AL
STL A,*AR0(0)
;设置标志
LD *AR0(1),A
STM #0,AH
ADD #1,A
STL A,*AR0(1)
time_next: POPM AR0
POPM AH
POPM AL
POPM ST1
POPM ST0
RETE
b $
_boot_end: NOP
.end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -