📄 time.s
字号:
.module time.c
.area text(rom, con, rel)
.dbfile D:\NEWWOR~1\motor\time.c
.dbfunc e Time1Init _Time1Init fV
.even
_Time1Init::
.dbline -1
.dbline 13
; #include <iom64v.h>
; #include <macros.h>
; #include "head.h"
;
;
; /*-----------------------------------------------------------------
; 函数名称: void Timer1Init(void)
; 函数功能: 定时器1初始化 256预分频 定时一秒
; 参 数:
; 返 回 值: 无
; -----------------------------------------------------------------*/
; void Time1Init()
; {
.dbline 14
; CLI(); //关全部中断 //开中断
cli
.dbline 15
; TCCR1B = 0x00; //关定时器
clr R2
out 0x2e,R2
.dbline 16
; TCNT1H = 0xF0; //设置定时初值
ldi R24,240
out 0x2d,R24
.dbline 17
; TCNT1L = 0xBE;
ldi R24,190
out 0x2c,R24
.dbline 18
; OCR1AH = 0x0F;
ldi R24,15
out 0x2b,R24
.dbline 19
; OCR1AL = 0x42;
ldi R24,66
out 0x2a,R24
.dbline 20
; OCR1BH = 0x0F;
ldi R24,15
out 0x29,R24
.dbline 21
; OCR1BL = 0x42;
ldi R24,66
out 0x28,R24
.dbline 22
; ICR1H = 0x0F;
ldi R24,15
out 0x27,R24
.dbline 23
; ICR1L = 0x42;
ldi R24,66
out 0x26,R24
.dbline 24
; TCCR1A = 0x00;
out 0x2f,R2
.dbline 25
; TCCR1B = 0x04; //开始计数
ldi R24,4
out 0x2e,R24
.dbline 27
;
; TIMSK = 0x04; //timer interrupt sources
out 0x37,R24
.dbline 28
; SEI();
sei
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 56
jmp _timer1_ovf_isr
.area text(rom, con, rel)
.dbfile D:\NEWWOR~1\motor\time.c
.dbfunc e timer1_ovf_isr _timer1_ovf_isr fV
.even
_timer1_ovf_isr::
st -y,R2
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 33
; }
;
; #pragma interrupt_handler timer1_ovf_isr:15
; void timer1_ovf_isr(void)
; {
.dbline 35
;
; TCNT1H = 0xF0; //重新装载计数值
ldi R24,240
out 0x2d,R24
.dbline 36
; TCNT1L = 0xBE;
ldi R24,190
out 0x2c,R24
.dbline 37
; if(temp){
lds R2,_temp
tst R2
breq L3
.dbline 37
.dbline 38
; g_ucLedStatus=0x00;
clr R2
sts _g_ucLedStatus,R2
.dbline 39
; PORTF = g_ucLedStatus;
sts 98,R2
.dbline 40
; temp=0;
sts _temp,R2
.dbline 41
xjmp L4
L3:
.dbline 41
.dbline 42
ldi R24,255
sts _g_ucLedStatus,R24
.dbline 43
mov R2,R24
sts 98,R2
.dbline 44
ldi R24,1
sts _temp,R24
.dbline 45
L4:
.dbline -2
L2:
ld R2,y+
out 0x3f,R2
ld R24,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -