📄 mega16test.s
字号:
.module mega16test.c
.area text(rom, con, rel)
.dbfile E:\设计练习\每周练习\暑假培训\1602\avr1602\mega16test.c
.dbfunc e port_init _port_init fV
.even
_port_init::
.dbline -1
.dbline 6
; #include <iom16v.h>
; #define uchar unsigned char
; #define fosc 12000000 //晶振7.3728MHZ
;
; void port_init(void)
; {
.dbline 7
; PORTA = 0xFF;
ldi R24,255
out 0x1b,R24
.dbline 8
; DDRA = 0x00;
clr R2
out 0x1a,R2
.dbline 9
; PORTB = 0xFF;
out 0x18,R24
.dbline 10
; DDRB = 0x00;
out 0x17,R2
.dbline 11
; PORTC = 0xFF; //m103 output only
out 0x15,R24
.dbline 12
; DDRC = 0xFF;
out 0x14,R24
.dbline 13
; PORTD = 0xFF;
out 0x12,R24
.dbline 14
; DDRD = 0x00;
out 0x11,R2
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e delay _delay fV
; i -> R20
; j -> R22
; t -> R16
.even
_delay::
xcall push_gset2
.dbline -1
.dbline 18
; }
;
; void delay(uchar t)
; {
.dbline 20
; uchar i,j;
; for(i=0;i<t;i++)
clr R20
xjmp L6
L3:
.dbline 21
clr R22
xjmp L10
L7:
.dbline 21
L8:
.dbline 21
inc R22
L10:
.dbline 21
cpi R22,250
brlo L7
L4:
.dbline 20
inc R20
L6:
.dbline 20
cp R20,R16
brlo L3
.dbline -2
L2:
xcall pop_gset2
.dbline 0 ; func end
ret
.dbsym r i 20 c
.dbsym r j 22 c
.dbsym r t 16 c
.dbend
.dbfunc e main _main fV
.even
_main::
.dbline -1
.dbline 27
; for(j=0;j<250;j++);
; }
;
;
; /* RS232通信main函数 */
; void main(void)
; {
.dbline 28
; port_init();
xcall _port_init
.dbline 29
; PORTC = 0x0;
clr R2
out 0x15,R2
xjmp L13
L12:
.dbline 31
.dbline 32
ldi R16,250
xcall _delay
.dbline 32
ldi R16,250
xcall _delay
.dbline 32
ldi R16,250
xcall _delay
.dbline 33
ldi R16,250
xcall _delay
.dbline 33
ldi R16,250
xcall _delay
.dbline 33
ldi R16,250
xcall _delay
.dbline 34
ldi R16,250
xcall _delay
.dbline 34
ldi R16,250
xcall _delay
.dbline 34
ldi R16,250
xcall _delay
.dbline 35
ldi R24,255
out 0x15,R24
.dbline 36
ldi R16,250
xcall _delay
.dbline 36
ldi R16,250
xcall _delay
.dbline 36
ldi R16,250
xcall _delay
.dbline 37
ldi R16,250
xcall _delay
.dbline 37
ldi R16,250
xcall _delay
.dbline 37
ldi R16,250
xcall _delay
.dbline 38
ldi R16,250
xcall _delay
.dbline 38
ldi R16,250
xcall _delay
.dbline 38
ldi R16,250
xcall _delay
.dbline 39
clr R2
out 0x15,R2
.dbline 40
L13:
.dbline 30
xjmp L12
X0:
.dbline -2
L11:
.dbline 0 ; func end
ret
.dbend
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -