📄 uart.s
字号:
.module Uart.c
.area text(rom, con, rel)
.dbfile D:\Datasheet\Atmel\FROMJI~1\AVR_Demo\m8\SoftWare\Uart.c
.dbfunc e uart0_RX_Enable _uart0_RX_Enable fV
.even
_uart0_RX_Enable::
.dbline -1
.dbline 7
;
; #include <iom8v.h>
; #include <macros.h>
; #include "Uart.h"
;
; void uart0_RX_Enable(void)
; {
.dbline 8
; UCSRB = 0xE8; //disable while setting baud rate
ldi R24,232
out 0xa,R24
.dbline -2
L1:
.dbline 0 ; func end
ret
.dbend
.dbfunc e uart0_RX_Disable _uart0_RX_Disable fV
.even
_uart0_RX_Disable::
.dbline -1
.dbline 11
; }
; void uart0_RX_Disable(void)
; {
.dbline 12
; UCSRB = 0xF8; //disable while setting baud rate
ldi R24,248
out 0xa,R24
.dbline -2
L2:
.dbline 0 ; func end
ret
.dbend
.dbfunc e uart0_init _uart0_init fV
.even
_uart0_init::
.dbline -1
.dbline 16
; }
;
; void uart0_init(void)
; {
.dbline 17
; UCSRB = 0x00; //disable while setting baud rate
clr R2
out 0xa,R2
.dbline 18
; UCSRA = 0x00;
out 0xb,R2
.dbline 19
; UCSRC = 0x86;
ldi R24,134
out 0x20,R24
.dbline 20
; UBRRL = 0x0B; //set baud rate lo
ldi R24,11
out 0x9,R24
.dbline 21
; UBRRH = 0x00; //set baud rate hi
out 0x20,R2
.dbline 22
; UCSRB = 0xF8;
ldi R24,248
out 0xa,R24
.dbline -2
L3:
.dbline 0 ; func end
ret
.dbend
.area vector(rom, abs)
.org 22
rjmp _uart0_rx_isr
.area text(rom, con, rel)
.dbfile D:\Datasheet\Atmel\FROMJI~1\AVR_Demo\m8\SoftWare\Uart.c
.dbfunc e uart0_rx_isr _uart0_rx_isr fV
; tempdata -> R20
.even
_uart0_rx_isr::
rcall push_lset
rcall push_gset1
.dbline -1
.dbline 26
.dbline 27
in R20,0xc
.dbline 28
mov R16,R20
rcall _PutChar
.dbline 31
ldi R16,<L5
ldi R17,>L5
rcall _PutStr
.dbline 32
ldi R16,<L6
ldi R17,>L6
rcall _PutStr
.dbline 34
cpi R20,73
brne L7
.dbline 35
.dbline 35
cli
.dbline 36
clr R2
out 0xa,R2
.dbline 37
JMP 0x1C00
.dbline 38
L7:
.dbline -2
L4:
rcall pop_gset1
rcall pop_lset
.dbline 0 ; func end
reti
.dbsym r tempdata 20 c
.dbend
.area vector(rom, abs)
.org 24
rjmp _uart0_udre_isr
.area text(rom, con, rel)
.dbfile D:\Datasheet\Atmel\FROMJI~1\AVR_Demo\m8\SoftWare\Uart.c
.dbfunc e uart0_udre_isr _uart0_udre_isr fV
.even
_uart0_udre_isr::
.dbline -1
.dbline 43
; }
; #pragma interrupt_handler uart0_rx_isr:12
; void uart0_rx_isr(void)
; { unsigned char tempdata;
; tempdata = UDR; /* read the received data */
; PutChar( tempdata);
; // PutChar(0x0a);
; // PutChar(0x0d);
; PutStr("富友勤 ATMEGA8 DEMO");
; PutStr("Start IAP");
;
; if(tempdata=='I')
; { CLI();
; UCSRB = 0x00;
; asm("JMP 0x1C00") ;
; }
; }
;
; #pragma interrupt_handler uart0_udre_isr:13
; void uart0_udre_isr(void)
; {
.dbline -2
L9:
.dbline 0 ; func end
reti
.dbend
.area vector(rom, abs)
.org 26
rjmp _uart0_tx_isr
.area text(rom, con, rel)
.dbfile D:\Datasheet\Atmel\FROMJI~1\AVR_Demo\m8\SoftWare\Uart.c
.dbfunc e uart0_tx_isr _uart0_tx_isr fV
.even
_uart0_tx_isr::
.dbline -1
.dbline 50
; //character transferred to shift register so UDR is now empty
;
; }
;
; #pragma interrupt_handler uart0_tx_isr:14
; void uart0_tx_isr(void)
; {
.dbline -2
L10:
.dbline 0 ; func end
reti
.dbend
.dbfunc e PutStr _PutStr fI
; s -> R16,R17
.even
_PutStr::
.dbline -1
.dbline 55
; }
;
;
; int PutStr(char *s)
; {
rjmp L13
X0:
.dbline 57
; while(*s)
; {while ( !(UCSRA & (1<<UDRE)) )
L15:
.dbline 58
L16:
.dbline 57
sbis 0xb,5
rjmp L15
.dbline 59
movw R30,R16
ldd R2,z+0
out 0xc,R2
.dbline 61
subi R16,255 ; offset = 1
sbci R17,255
.dbline 62
L13:
.dbline 56
movw R30,R16
ldd R2,z+0
tst R2
brne L16
L18:
.dbline 66
L19:
.dbline 65
; ; /* wait for empty transmit buffer */
; UDR = *s; /* start transmittion */
;
; s++;
; }
;
;
; while ( !(UCSRA & (1<<UDRE)) )
sbis 0xb,5
rjmp L18
.dbline 67
; ; /* wait for empty transmit buffer */
; UDR = 0x0a; /* start transmittion */
ldi R24,10
out 0xc,R24
.dbline 69
; //while ( !(UCSRA & (1<<UDRE)) )
; ; /* wait for empty transmit buffer */
.dbline 71
; //UDR = 0x0d; /* start transmittion */
; return 1;
ldi R16,1
ldi R17,0
.dbline -2
L11:
.dbline 0 ; func end
ret
.dbsym r s 16 pc
.dbend
.dbfunc e PutInt _PutInt fV
; intdata -> R0,R1
.even
_PutInt::
.dbline 0 ; func end
ret
.dbsym l intdata 0 i
.dbend
.dbfunc e PutChar _PutChar fV
; c -> R0
.even
_PutChar::
.dbline 0 ; func end
ret
.dbsym l c 0 c
.dbend
.area data(ram, con, rel)
.dbfile D:\Datasheet\Atmel\FROMJI~1\AVR_Demo\m8\SoftWare\Uart.c
L6:
.blkb 10
.area idata
.byte 'S,'t,'a,'r,'t,32,'I,'A,'P,0
.area data(ram, con, rel)
.dbfile D:\Datasheet\Atmel\FROMJI~1\AVR_Demo\m8\SoftWare\Uart.c
L5:
.blkb 20
.area idata
.byte 184,187,211,209,199,218,32,'A,'T,'M,'E,'G,'A,56,32,'D
.byte 'E,'M,'O,0
.area data(ram, con, rel)
.dbfile D:\Datasheet\Atmel\FROMJI~1\AVR_Demo\m8\SoftWare\Uart.c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -