📄 time.s
字号:
.module time.c
.area data(ram, con, rel)
_time_flag::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile F:\IccAvr_Pro\time.c
.dbsym e time_flag _time_flag c
_pwm::
.blkb 1
.area idata
.byte 127
.area data(ram, con, rel)
.dbfile F:\IccAvr_Pro\time.c
.dbsym e pwm _pwm c
.area vector(rom, abs)
.org 16
jmp _timer2_ovf_isr
.area data(ram, con, rel)
.dbfile F:\IccAvr_Pro\time.c
.area text(rom, con, rel)
.dbfile F:\IccAvr_Pro\time.c
.dbfunc e timer2_ovf_isr _timer2_ovf_isr fV
.even
_timer2_ovf_isr::
st -y,R2
st -y,R3
st -y,R16
st -y,R17
st -y,R18
st -y,R19
st -y,R24
in R2,0x3f
st -y,R2
.dbline -1
.dbline 10
;
; #include "time.h"
;
; unsigned char time_flag=0;
; unsigned char pwm=0x7f;
; extern int F;
; extern int qep_cnt[];
; #pragma interrupt_handler timer2_ovf_isr:5
; void timer2_ovf_isr(void)
; {
.dbline 11
; TCNT2 = 0x64; //reload counter value
ldi R24,100
out 0x24,R24
.dbline 12
; time_flag=1;
ldi R24,1
sts _time_flag,R24
.dbline 13
; F=qep_cnt[0]*6;
lds R18,_qep_cnt
lds R19,_qep_cnt+1
ldi R16,6
ldi R17,0
xcall empy16s
sts _F+1,R17
sts _F,R16
.dbline 14
; qep_cnt[0]=0;
clr R2
clr R3
sts _qep_cnt+1,R3
sts _qep_cnt,R2
.dbline -2
.dbline 15
; }
L1:
ld R2,y+
out 0x3f,R2
ld R24,y+
ld R19,y+
ld R18,y+
ld R17,y+
ld R16,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e timer2_init _timer2_init fV
.even
_timer2_init::
.dbline -1
.dbline 22
;
; //TIMER2 initialize - prescale:256
; // WGM: Normal
; // desired value: 5mSec
; // actual value: 4.965mSec (0.7%)
; void timer2_init(void)
; {
.dbline 23
; TCCR2 = 0x00; //stop
clr R2
out 0x25,R2
.dbline 24
; ASSR = 0x00; //set async mode
out 0x22,R2
.dbline 25
; TCNT2 = 0x64; //setup
ldi R24,100
out 0x24,R24
.dbline 26
; OCR2 = 0x9C;
ldi R24,156
out 0x23,R24
.dbline 27
; TCCR2 = 0x06; //start
ldi R24,6
out 0x25,R24
.dbline 28
; time_flag=0;
sts _time_flag,R2
.dbline -2
.dbline 29
; }
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer1_init _timer1_init fV
.even
_timer1_init::
.dbline -1
.dbline 36
;
; //TIMER1 initialize - prescale:1
; // WGM: 8) PWM phz freq correct, TOP=ICRn
; // desired value: 14.4KHz
; // actual value: 14.456KHz (0.4%)
; void timer1_init(void)
; {
.dbline 37
; DDRD|=BIT(PORTD4)|BIT(PORTD5);
in R24,0x11
ori R24,48
out 0x11,R24
.dbline 38
; TCCR1B = 0x00; //stop
clr R2
out 0x2e,R2
.dbline 39
; TCNT1H = 0xFF; //setup
ldi R24,255
out 0x2d,R24
.dbline 40
; TCNT1L = 0x01;
ldi R24,1
out 0x2c,R24
.dbline 41
; OCR1AH = 0x00;
out 0x2b,R2
.dbline 42
; OCR1AL = 0x7f;
ldi R24,127
out 0x2a,R24
.dbline 43
; OCR1BH = 0x00;
out 0x29,R2
.dbline 44
; OCR1BL = 0x7f;
out 0x28,R24
.dbline 45
; ICR1H = 0x00;
out 0x27,R2
.dbline 46
; ICR1L = 0xFF;
ldi R24,255
out 0x26,R24
.dbline 47
; TCCR1A = 0xA0;
ldi R24,160
out 0x2f,R24
.dbline 48
; TCCR1B = 0x11; //start Timer
ldi R24,17
out 0x2e,R24
.dbline -2
.dbline 49
; }
L3:
.dbline 0 ; func end
ret
.dbend
.dbfunc e pwm_change _pwm_change fV
; pwm -> R16
.even
_pwm_change::
.dbline -1
.dbline 51
; void pwm_change(unsigned char pwm)
; {
.dbline 52
; OCR1AH = 0x00;
clr R2
out 0x2b,R2
.dbline 53
; OCR1AL = pwm;
out 0x2a,R16
.dbline 54
; OCR1BH = 0x00;
out 0x29,R2
.dbline 55
; OCR1BL = pwm;
out 0x28,R16
.dbline 56
; ICR1H = 0x00;
out 0x27,R2
.dbline -2
.dbline 58
;
; }
L4:
.dbline 0 ; func end
ret
.dbsym r pwm 16 c
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -