📄 uart.lis
字号:
.module uart.c
.area text(rom, con, rel)
0000 .dbfile uart.c
0000 .dbfunc e port_init _port_init fV
.even
0000 _port_init::
0000 .dbline -1
0000 .dbline 15
0000 ; //ICC-AVR application builder : 2005-5-1 15:44:13
0000 ; // Target : M16
0000 ; // Crystal: 6.0000Mhz
0000 ;
0000 ; #include <iom16v.h>
0000 ; #include <macros.h>
0000 ;
0000 ; #define b19200 ox19
0000 ; #define b9600 0x26
0000 ; #define baud b9600
0000 ;
0000 ; unsigned char com_in_buf[1];
0000 ;
0000 ; void port_init(void)
0000 ; {
0000 .dbline 16
0000 ; PORTA = 0xFF;
0000 8FEF ldi R24,255
0002 8BBB out 0x1b,R24
0004 .dbline 17
0004 ; DDRA = 0xFF;
0004 8ABB out 0x1a,R24
0006 .dbline 18
0006 ; PORTB = 0x00;
0006 2224 clr R2
0008 28BA out 0x18,R2
000A .dbline 19
000A ; DDRB = 0x00;
000A 27BA out 0x17,R2
000C .dbline 20
000C ; PORTC = 0x00; //m103 output only
000C 25BA out 0x15,R2
000E .dbline 21
000E ; DDRC = 0x00;
000E 24BA out 0x14,R2
0010 .dbline 22
0010 ; PORTD = 0x00;
0010 22BA out 0x12,R2
0012 .dbline 23
0012 ; DDRD = 0x00;
0012 21BA out 0x11,R2
0014 .dbline -2
0014 L1:
0014 .dbline 0 ; func end
0014 0895 ret
0016 .dbend
0016 .dbfunc e uart0_init _uart0_init fV
.even
0016 _uart0_init::
0016 .dbline -1
0016 .dbline 32
0016 ; }
0016 ;
0016 ; //UART0 initialize
0016 ; // desired baud rate: 9600
0016 ; // actual: baud rate:9615 (0.2%)
0016 ; // char size: 8 bit
0016 ; // parity: Disabled
0016 ; void uart0_init(void)
0016 ; {
0016 .dbline 33
0016 ; UCSRB = 0x00; //disable while setting baud rate
0016 2224 clr R2
0018 2AB8 out 0xa,R2
001A .dbline 34
001A ; UCSRA = 0x00;
001A 2BB8 out 0xb,R2
001C .dbline 35
001C ; UCSRC = BIT(URSEL) | 0x06;
001C 86E8 ldi R24,134
001E 80BD out 0x20,R24
0020 .dbline 36
0020 ; UBRRL = baud; //set baud rate lo
0020 86E2 ldi R24,38
0022 89B9 out 0x9,R24
0024 .dbline 37
0024 ; UBRRH = 0x00; //set baud rate hi
0024 20BC out 0x20,R2
0026 .dbline 38
0026 ; UCSRB = 0x98;
0026 88E9 ldi R24,152
0028 8AB9 out 0xa,R24
002A .dbline -2
002A L2:
002A .dbline 0 ; func end
002A 0895 ret
002C .dbend
002C .dbfunc e send_data _send_data fV
002C ; back -> R16
.even
002C _send_data::
002C .dbline -1
002C .dbline 42
002C ; }
002C ;
002C ; void send_data(unsigned char back)
002C ; {
002C L4:
002C .dbline 43
002C L5:
002C .dbline 43
002C ; while( !( UCSRA & (1<<UDRE)) ) ;
002C 5D9B sbis 0xb,5
002E FECF rjmp L4
0030 .dbline 44
0030 ; UDR=back;
0030 0CB9 out 0xc,R16
0032 .dbline -2
0032 L3:
0032 .dbline 0 ; func end
0032 0895 ret
0034 .dbsym r back 16 c
0034 .dbend
.area vector(rom, abs)
.org 44
002C 0C941A00 jmp _uart0_rx_isr
.area text(rom, con, rel)
0034 .dbfile uart.c
0034 .dbfunc e uart0_rx_isr _uart0_rx_isr fV
.even
0034 _uart0_rx_isr::
0034 0E940000 xcall push_lset
0038 .dbline -1
0038 .dbline 49
0038 ; }
0038 ;
0038 ; #pragma interrupt_handler uart0_rx_isr:12
0038 ; void uart0_rx_isr(void)
0038 ; {
0038 .dbline 51
0038 ; //uart has received a character in UDR
0038 ; com_in_buf[0]=UDR;
0038 2CB0 in R2,0xc
003A 20920000 sts _com_in_buf,R2
003E .dbline 52
003E ; PORTA =~com_in_buf[0];
003E 2094 com R2
0040 2BBA out 0x1b,R2
0042 .dbline 53
0042 ; send_data(com_in_buf[0]);
0042 00910000 lds R16,_com_in_buf
0046 F2DF xcall _send_data
0048 .dbline -2
0048 L7:
0048 0E940000 xcall pop_lset
004C .dbline 0 ; func end
004C 1895 reti
004E .dbend
004E .dbfunc e init_devices _init_devices fV
.even
004E _init_devices::
004E .dbline -1
004E .dbline 58
004E ; }
004E ;
004E ; //call this routine to initialize all peripherals
004E ; void init_devices(void)
004E ; {
004E .dbline 60
004E ; //stop errant interrupts until set up
004E ; CLI(); //disable all interrupts
004E F894 cli
0050 .dbline 61
0050 ; port_init();
0050 D7DF xcall _port_init
0052 .dbline 62
0052 ; uart0_init();
0052 E1DF xcall _uart0_init
0054 .dbline 64
0054 ;
0054 ; MCUCR = 0x00;
0054 2224 clr R2
0056 25BE out 0x35,R2
0058 .dbline 65
0058 ; GICR = 0x00;
0058 2BBE out 0x3b,R2
005A .dbline 66
005A ; TIMSK = 0x00; //timer interrupt sources
005A 29BE out 0x39,R2
005C .dbline 67
005C ; SEI(); //re-enable interrupts
005C 7894 sei
005E .dbline -2
005E L8:
005E .dbline 0 ; func end
005E 0895 ret
0060 .dbend
0060 .dbfunc e main _main fV
0060 ; j -> R20
.even
0060 _main::
0060 .dbline -1
0060 .dbline 72
0060 ; //all peripherals are now initialized
0060 ; }
0060 ;
0060 ; void main(void)
0060 ; {
0060 .dbline 74
0060 ; char j;
0060 ; init_devices();
0060 F6DF xcall _init_devices
0062 05C0 xjmp L11
0064 L10:
0064 .dbline 76
0064 ; while(1)
0064 ; {
0064 .dbline 77
0064 ; for(j=1;j<100;j++)
0064 41E0 ldi R20,1
0066 01C0 xjmp L16
0068 L13:
0068 .dbline 78
0068 L14:
0068 .dbline 77
0068 4395 inc R20
006A L16:
006A .dbline 77
006A 4436 cpi R20,100
006C E8F3 brlo L13
006E .dbline 79
006E L11:
006E .dbline 75
006E FACF xjmp L10
0070 X0:
0070 .dbline -2
0070 L9:
0070 .dbline 0 ; func end
0070 0895 ret
0072 .dbsym r j 20 c
0072 .dbend
.area bss(ram, con, rel)
0000 .dbfile uart.c
0000 _com_in_buf::
0000 .blkb 1
0001 .dbsym e com_in_buf _com_in_buf A[1:1]c
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -