📄 main.s
字号:
.module main.c
.area text(rom, con, rel)
.dbfile E:\ICCAVR\project\AVRMEG~3\icc\007-T1-LED\main.c
.dbfunc e t1_init _t1_init fV
.even
_t1_init::
.dbline -1
.dbline 18
; /*
; 实验七:
; 定时器T1中断实验。
; 1、定时器中断实验。定时器产生10mS周期中断,通过计数让PB0电平产生周期变化。
; 2、内部1 M晶振。
; 3、进行此实验请插上LED短路块。
; 4、此实验使用定时器的溢出中断方式,为定时器的最基本方式。
;
; AVR mega128学习板 阿发
; www.iccavr.com
; 2:15 2007-10-11
; */
;
; #include "iom128v.h"
; #include <macros.h>
;
; /*初始化定时器,产生10mS周期中断*/
; void t1_init(void) {
.dbline 20
;
; OCR1A = 1250; /*计数周期为10mS,F=1M*/
ldi R24,1250
ldi R25,4
out 0x2b,R25
out 0x2a,R24
.dbline 21
; TIMSK |= (1 << OCIE1A); /*比较中断A允许*/
in R24,0x37
ori R24,16
out 0x37,R24
.dbline 22
; TCCR1A = 0x00;
clr R2
out 0x2f,R2
.dbline 23
; TCCR1B = (1 << WGM12); /*定时器工作在CTC计数器模式*/
ldi R24,8
out 0x2e,R24
.dbline 24
; TCCR1B |= (1 << CS11); /*设置定时器的分频值为8分频*/
in R24,0x2e
ori R24,2
out 0x2e,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e io_init _io_init fV
.even
_io_init::
.dbline -1
.dbline 28
; }
;
; /*IO口初始化函数*/
; void io_init(void) {
.dbline 30
;
; DDRA = 0x00; /*方向输入*/
clr R2
out 0x1a,R2
.dbline 31
; PORTA = 0xFF; /*打开上拉*/
ldi R24,255
out 0x1b,R24
.dbline 32
; DDRB = 0xFF; /*方向输出*/
out 0x17,R24
.dbline 33
; PORTB = 0xFF; /*输出高电平*/
out 0x18,R24
.dbline 34
; DDRC = 0x00; /*不用的IO口建议设置为输入带上拉*/
out 0x14,R2
.dbline 35
; PORTC = 0xFF;
out 0x15,R24
.dbline 36
; DDRD = 0x00;
out 0x11,R2
.dbline 37
; PORTD = 0xFF;
out 0x12,R24
.dbline 38
; DDRE = 0x00;
out 0x2,R2
.dbline 39
; PORTE = 0xFF;
out 0x3,R24
.dbline 40
; DDRF = 0x00;
sts 97,R2
.dbline 41
; PORTF = 0xFF;
sts 98,R24
.dbline 42
; DDRG = 0x00;
sts 100,R2
.dbline 43
; PORTG = 0xFF;
sts 101,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 46
; }
;
; void main(void) {
.dbline 48
;
; io_init();
xcall _io_init
.dbline 49
; t1_init();
xcall _t1_init
.dbline 50
; SEI(); /*全局中断使能*/
sei
L4:
.dbline 52
L5:
.dbline 52
xjmp L4
X0:
.dbline -2
L3:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 48
jmp _Int_TCCR1A
.area text(rom, con, rel)
.dbfile E:\ICCAVR\project\AVRMEG~3\icc\007-T1-LED\main.c
.area bss(ram, con, rel)
.dbfile E:\ICCAVR\project\AVRMEG~3\icc\007-T1-LED\main.c
L8:
.blkb 1
.area text(rom, con, rel)
.dbfile E:\ICCAVR\project\AVRMEG~3\icc\007-T1-LED\main.c
.dbfunc e Int_TCCR1A _Int_TCCR1A fV
.dbsym s i L8 c
.even
_Int_TCCR1A::
st -y,R2
st -y,R24
st -y,R25
in R2,0x3f
st -y,R2
.dbline -1
.dbline 57
.dbline 61
lds R24,L8
subi R24,255 ; addi 1
sts L8,R24
.dbline 62
ldi R24,100
lds R2,L8
cp R24,R2
brsh L9
.dbline 62
.dbline 63
ldi R24,1
in R2,0x18
eor R2,R24
out 0x18,R2
.dbline 64
clr R2
sts L8,R2
.dbline 65
L9:
.dbline -2
L7:
ld R2,y+
out 0x3f,R2
ld R25,y+
ld R24,y+
ld R2,y+
.dbline 0 ; func end
reti
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -