📄 usart.lis
字号:
.module USART.C
.area text(rom, con, rel)
0000 .dbfile C:\DOCUME~1\pas\桌面\test\USART\USART.C
0000 .dbfunc e port_init _port_init fV
.even
0000 _port_init::
0000 .dbline -1
0000 .dbline 5
0000 ; #include <iom32v.h>
0000 ; #include <macros.h>
0000 ; #include <stdio.h>
0000 ; void port_init(void)
0000 ; {
0000 .dbline 6
0000 ; PORTA = 0x00;
0000 2224 clr R2
0002 2BBA out 0x1b,R2
0004 .dbline 7
0004 ; DDRA = 0x00;
0004 2ABA out 0x1a,R2
0006 .dbline 8
0006 ; PORTB = 0x00;
0006 28BA out 0x18,R2
0008 .dbline 9
0008 ; DDRB = 0x00;
0008 27BA out 0x17,R2
000A .dbline 10
000A ; PORTC = 0x00; //m103 output only
000A 25BA out 0x15,R2
000C .dbline 11
000C ; DDRC = 0x00;
000C 24BA out 0x14,R2
000E .dbline 12
000E ; PORTD = 0x02;
000E 82E0 ldi R24,2
0010 82BB out 0x12,R24
0012 .dbline 13
0012 ; DDRD = 0xff;
0012 8FEF ldi R24,255
0014 81BB out 0x11,R24
0016 .dbline -2
0016 L1:
0016 .dbline 0 ; func end
0016 0895 ret
0018 .dbend
0018 .dbfunc e uart0_init _uart0_init fV
.even
0018 _uart0_init::
0018 .dbline -1
0018 .dbline 22
0018 ; }
0018 ;
0018 ; //UART0 initialize
0018 ; // desired baud rate: 9600
0018 ; // actual: baud rate:9615 (0.2%)
0018 ; // char size: 8 bit
0018 ; // parity: Disabled
0018 ; void uart0_init(void)
0018 ; {
0018 .dbline 23
0018 ; UCSRB = 0x00; //disable while setting baud rate
0018 2224 clr R2
001A 2AB8 out 0xa,R2
001C .dbline 24
001C ; UCSRA = 0x00;
001C 2BB8 out 0xb,R2
001E .dbline 25
001E ; UCSRC = BIT(URSEL) | 0x06;
001E 86E8 ldi R24,134
0020 80BD out 0x20,R24
0022 .dbline 26
0022 ; UBRRL = 0x2F; //set baud rate lo
0022 8FE2 ldi R24,47
0024 89B9 out 0x9,R24
0026 .dbline 27
0026 ; UBRRH = 0x00; //set baud rate hi
0026 20BC out 0x20,R2
0028 .dbline 28
0028 ; UCSRB = 0x18;
0028 88E1 ldi R24,24
002A 8AB9 out 0xa,R24
002C .dbline -2
002C L2:
002C .dbline 0 ; func end
002C 0895 ret
002E .dbend
002E .dbfunc e init_devices _init_devices fV
.even
002E _init_devices::
002E .dbline -1
002E .dbline 33
002E ; }
002E ;
002E ; //call this routine to initialize all peripherals
002E ; void init_devices(void)
002E ; {
002E .dbline 35
002E ; //stop errant interrupts until set up
002E ; CLI(); //disable all interrupts
002E F894 cli
0030 .dbline 36
0030 ; port_init();
0030 E7DF xcall _port_init
0032 .dbline 37
0032 ; uart0_init();
0032 F2DF xcall _uart0_init
0034 .dbline 39
0034 ;
0034 ; MCUCR = 0x00;
0034 2224 clr R2
0036 25BE out 0x35,R2
0038 .dbline 40
0038 ; GICR = 0x00;
0038 2BBE out 0x3b,R2
003A .dbline 41
003A ; TIMSK = 0x00; //timer interrupt sources
003A 29BE out 0x39,R2
003C .dbline 42
003C ; SEI(); //re-enable interrupts
003C 7894 sei
003E .dbline -2
003E L3:
003E .dbline 0 ; func end
003E 0895 ret
0040 .dbend
0040 .dbfunc e Puts _Puts fV
0040 ; s -> R20,R21
.even
0040 _Puts::
0040 0E940000 xcall push_gset1
0044 A801 movw R20,R16
0046 .dbline -1
0046 .dbline 46
0046 ; //all peripherals are now initialized
0046 ; }
0046 ; void Puts( unsigned char *s) // \arg pointer to a string ending by \0
0046 ; {
0046 06C0 xjmp L6
0048 L5:
0048 .dbline 49
0048 .dbline 50
0048 FA01 movw R30,R20
004A 0081 ldd R16,z+0
004C 0E940000 xcall _putchar
0050 .dbline 51
0050 4F5F subi R20,255 ; offset = 1
0052 5F4F sbci R21,255
0054 .dbline 52
0054 L6:
0054 .dbline 48
0054 ;
0054 ; while (*s)
0054 FA01 movw R30,R20
0056 2080 ldd R2,z+0
0058 2220 tst R2
005A B1F7 brne L5
005C .dbline -2
005C L4:
005C 0E940000 xcall pop_gset1
0060 .dbline 0 ; func end
0060 0895 ret
0062 .dbsym r s 20 pc
0062 .dbend
0062 .dbfunc e main _main fV
.even
0062 _main::
0062 .dbline -1
0062 .dbline 56
0062 ; {
0062 ; putchar(*s);
0062 ; s++;
0062 ; }
0062 ; }
0062 ;
0062 ; void main(void)
0062 ; {
0062 .dbline 57
0062 ; init_devices();
0062 E5DF xcall _init_devices
0064 04C0 xjmp L10
0066 L9:
0066 .dbline 59
0066 .dbline 60
0066 00E0 ldi R16,<L12
0068 10E0 ldi R17,>L12
006A 0E940000 xcall _puts
006E .dbline 61
006E L10:
006E .dbline 58
006E FBCF xjmp L9
0070 X0:
0070 .dbline -2
0070 L8:
0070 .dbline 0 ; func end
0070 0895 ret
0072 .dbend
.area data(ram, con, rel)
0000 .dbfile C:\DOCUME~1\pas\桌面\test\USART\USART.C
0000 L12:
0000 .blkb 34
.area idata
0000 5757572E4F55524156522E434F4D204D .byte 'W,'W,'W,46,'O,'U,'R,'A,'V,'R,46,'C,'O,'M,32,'M
0010 59204E414D4520495320504153594F4E .byte 'Y,32,'N,'A,'M,'E,32,'I,'S,32,'P,'A,'S,'Y,'O,'N
0020 4700 .byte 'G,0
.area data(ram, con, rel)
0022 .dbfile C:\DOCUME~1\pas\桌面\test\USART\USART.C
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -