📄 time0.s
字号:
.module time0.c
.area data(ram, con, rel)
_i::
.blkb 1
.area idata
.byte 0
.area data(ram, con, rel)
.dbfile E:\ICCAVR编程学习\定时计数器学习\time0.c
.dbsym e i _i c
_timecount::
.blkb 2
.area idata
.word 0
.area data(ram, con, rel)
.dbfile E:\ICCAVR编程学习\定时计数器学习\time0.c
.dbsym e timecount _timecount i
.area text(rom, con, rel)
.dbfile E:\ICCAVR编程学习\定时计数器学习\time0.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 12
; //ICC-AVR application builder : 2007-3-8 22:08:41
; // Target : M8
; // Crystal: 1.0000Mhz
;
; #include <iom8v.h>
; #include <macros.h>
; #include <stdio.h>
;
; char i=0;
; unsigned int timecount=0;
; void port_init(void)
; {
.dbline 13
; PORTB = 0xFF;
ldi R24,255
out 0x18,R24
.dbline 14
; DDRB = 0xFF;
out 0x17,R24
.dbline 15
; PORTC = 0x7F; //m103 output only
ldi R24,127
out 0x15,R24
.dbline 16
; DDRC = 0x00;
clr R2
out 0x14,R2
.dbline 17
; PORTD = 0xFF;
ldi R24,255
out 0x12,R24
.dbline 18
; DDRD = 0xFF;
out 0x11,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e timer0_init _timer0_init fV
.even
_timer0_init::
.dbline -1
.dbline 25
; }
;
; //TIMER0 initialize - prescale:8
; // desired value: 1Hz
; // actual value: Out of range
; void timer0_init(void)
; {
.dbline 26
; TCCR0 = 0x00; //stop
clr R2
out 0x33,R2
.dbline 27
; TCNT0 = 6 /*INVALID SETTING*/; //set count
ldi R24,6
out 0x32,R24
.dbline 28
; TCCR0 = 0x02; //start timer
ldi R24,2
out 0x33,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 18
rjmp _timer0_ovf_isr
.area text(rom, con, rel)
.dbfile E:\ICCAVR编程学习\定时计数器学习\time0.c
.dbfunc e timer0_ovf_isr _timer0_ovf_isr fV
.even
_timer0_ovf_isr::
st -y,R2
st -y,R3
st -y,R24
st -y,R25
st -y,R30
in R2,0x3f
st -y,R2
.dbline -1
.dbline 34
.dbline 44
lds R24,_timecount
lds R25,_timecount+1
adiw R24,1
sts _timecount+1,R25
sts _timecount,R24
cpi R24,232
ldi R30,3
cpc R25,R30
brne L4
.dbline 45
.dbline 46
ldi R24,128
ldi R25,0
in R2,0x12
clr R3
eor R2,R24
eor R3,R25
out 0x12,R2
.dbline 47
clr R2
clr R3
sts _timecount+1,R3
sts _timecount,R2
.dbline 48
L4:
.dbline -2
L3:
ld R2,y+
out 0x3f,R2
ld R30,y+
ld R25,y+
ld R24,y+
ld R3,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
.dbfunc e init_devices _init_devices fV
.even
_init_devices::
.dbline -1
.dbline 54
;
; }
;
; #pragma interrupt_handler timer0_ovf_isr:10
; void timer0_ovf_isr(void)
; {
; //TCNT0 = 6 /*INVALID SETTING*/; //reload counter value
; /* if(i<10) //i决定循环基准时间的次数
; {TCNT0=0X3A; //重设初始值 100ms
; i++; //累加基准时间
; }
; else
; {PORTD^=BIT(0); //翻转PD口电平
; i=0; //定时全局变量恢复初始值
; } */
; if(++timecount==1000)
; {
; PORTD=PORTD^0x80;
; timecount=0;
; }
; }
;
;
; //call this routine to initialize all peripherals
; void init_devices(void)
; {
.dbline 56
; //stop errant interrupts until set up
; CLI(); //disable all interrupts
cli
.dbline 57
; timer0_init();
rcall _timer0_init
.dbline 58
; port_init();
rcall _port_init
.dbline 60
;
; MCUCR = 0x00;
clr R2
out 0x35,R2
.dbline 61
; GICR = 0x00;
out 0x3b,R2
.dbline 62
; TIMSK = 0x01; //timer interrupt sources
ldi R24,1
out 0x39,R24
.dbline 63
; SEI(); //re-enable interrupts
sei
.dbline -2
L6:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 69
; //all peripherals are now initialized
; }
;
; //
; void main(void)
; {
.dbline 79
; /*TCCR0=0X05; //时钟1024分频
; TCNT0=0X3A; //定时器计数初始值 100ms
; TIMSK=0X01; //允许定时器0中断
; SEI(); //开全局中断
; DDRB=0XFF;
; DDRD=0XFF;
; PORTB=0Xff;
; PORTD=0XFF; */
;
; init_devices();
rcall _init_devices
L8:
.dbline 80
L9:
.dbline 80
rjmp L8
X0:
.dbline -2
L7:
.dbline 0 ; func end
ret
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -