📄 main.lis
字号:
.module main.c
.area text(rom, con, rel)
0000 .dbfile C:\DOCUME~1\haolxy\桌面\smartcar\smartcar\main.c
0000 .dbfunc e port_init _port_init fV
.even
0000 _port_init::
0000 .dbline -1
0000 .dbline 21
0000 ; //ICC-AVR application builder : 2009-2-18 11:55:58
0000 ; // Target : M16
0000 ; // Crystal: 8.0000Mhz
0000 ;
0000 ; #include <iom16v.h>
0000 ; #include <macros.h>
0000 ; #define mclk 8000000
0000 ;
0000 ;
0000 ;
0000 ;
0000 ;
0000 ; //=============================================================
0000 ; // 函数名: void port_init(void)
0000 ; // 功能: 端口初始化,所有端口都变为高阻态
0000 ; // 参数: none
0000 ; // 返回值: none
0000 ; // 使用方法:port_init();
0000 ; //=============================================================
0000 ; void port_init(void)
0000 ; {
0000 .dbline 22
0000 ; DDRA = 0x00;
0000 2224 clr R2
0002 2ABA out 0x1a,R2
0004 .dbline 23
0004 ; PORTA = 0x00;
0004 2BBA out 0x1b,R2
0006 .dbline 24
0006 ; DDRB = 0x00;
0006 27BA out 0x17,R2
0008 .dbline 25
0008 ; PORTB = 0x00;
0008 28BA out 0x18,R2
000A .dbline 26
000A ; DDRC = 0x00;
000A 24BA out 0x14,R2
000C .dbline 27
000C ; PORTC = 0x00;
000C 25BA out 0x15,R2
000E .dbline 28
000E ; DDRD = 0x00;
000E 21BA out 0x11,R2
0010 .dbline 29
0010 ; PORTD = 0x00;
0010 22BA out 0x12,R2
0012 .dbline -2
0012 L1:
0012 .dbline 0 ; func end
0012 0895 ret
0014 .dbend
0014 .dbfunc e motor_a _motor_a fV
0014 ; speed -> R18,R19
0014 ; fx -> R16
.even
0014 _motor_a::
0014 .dbline -1
0014 .dbline 44
0014 ; }
0014 ;
0014 ;
0014 ; //////////////////////////////////////////////////////////////////////////////////////////////////////
0014 ;
0014 ;
0014 ; //=============================================================
0014 ; // 函数名: void motor_a(unsigned char fx,int speed)
0014 ; // 功能: 控制电机A的旋转方向以及转速
0014 ; // 参数: unsigned char fx,int speed fx为0或者1,speed为0-1023
0014 ; // 返回值: none
0014 ; // 使用方法:motor_a(0,1000);
0014 ; //=============================================================
0014 ; void motor_a(unsigned char fx,int speed)
0014 ; {
0014 .dbline 45
0014 ; if(fx)
0014 0023 tst R16
0016 19F0 breq L3
0018 .dbline 46
0018 ; {
0018 .dbline 47
0018 ; PORTB |= BIT(2);
0018 C29A sbi 0x18,2
001A .dbline 48
001A ; PORTB &= ~BIT(0);
001A C098 cbi 0x18,0
001C .dbline 49
001C ; }
001C 02C0 xjmp L4
001E L3:
001E .dbline 51
001E ; else
001E ; {
001E .dbline 52
001E ; PORTB |= BIT(0);
001E C09A sbi 0x18,0
0020 .dbline 53
0020 ; PORTB &= ~BIT(2);
0020 C298 cbi 0x18,2
0022 .dbline 54
0022 ; }
0022 L4:
0022 .dbline 55
0022 ; OCR1A = speed;
0022 3BBD out 0x2b,R19
0024 2ABD out 0x2a,R18
0026 .dbline -2
0026 L2:
0026 .dbline 0 ; func end
0026 0895 ret
0028 .dbsym r speed 18 I
0028 .dbsym r fx 16 c
0028 .dbend
0028 .dbfunc e motor_b _motor_b fV
0028 ; speed -> R18,R19
0028 ; fx -> R16
.even
0028 _motor_b::
0028 .dbline -1
0028 .dbline 66
0028 ; }
0028 ;
0028 ; //=============================================================
0028 ; // 函数名: void motor_b(unsigned char fx,int speed)
0028 ; // 功能: 控制电机A的旋转方向以及转速
0028 ; // 参数: unsigned char fx,int speed fx为0或者1,speed为0-1023
0028 ; // 返回值: none
0028 ; // 使用方法:motor_b(0,1000);
0028 ; //=============================================================
0028 ; void motor_b(unsigned char fx,int speed)
0028 ; {
0028 .dbline 67
0028 ; if(fx)
0028 0023 tst R16
002A 19F0 breq L6
002C .dbline 68
002C ; {
002C .dbline 69
002C ; PORTB |= BIT(4);
002C C49A sbi 0x18,4
002E .dbline 70
002E ; PORTB &= ~BIT(1);
002E C198 cbi 0x18,1
0030 .dbline 71
0030 ; }
0030 02C0 xjmp L7
0032 L6:
0032 .dbline 73
0032 ; else
0032 ; {
0032 .dbline 74
0032 ; PORTB |= BIT(1);
0032 C19A sbi 0x18,1
0034 .dbline 75
0034 ; PORTB &= ~BIT(4);
0034 C498 cbi 0x18,4
0036 .dbline 76
0036 ; }
0036 L7:
0036 .dbline 77
0036 ; OCR1B = speed;
0036 39BD out 0x29,R19
0038 28BD out 0x28,R18
003A .dbline -2
003A L5:
003A .dbline 0 ; func end
003A 0895 ret
003C .dbsym r speed 18 I
003C .dbsym r fx 16 c
003C .dbend
003C .dbfunc e motor_init _motor_init fV
.even
003C _motor_init::
003C .dbline -1
003C .dbline 87
003C ; }
003C ; //=============================================================
003C ; // 函数名: void motor_init(void)
003C ; // 功能: 电机控制初始化
003C ; // 参数: none
003C ; // 返回值: none
003C ; // 使用方法:motor_init();
003C ; //=============================================================
003C ; void motor_init(void)
003C ; {
003C .dbline 88
003C ; DDRB |= 0x17;
003C 87B3 in R24,0x17
003E 8761 ori R24,23
0040 87BB out 0x17,R24
0042 .dbline 89
0042 ; PORTB &= ~0x03;
0042 88B3 in R24,0x18
0044 8C7F andi R24,252
0046 88BB out 0x18,R24
0048 .dbline 90
0048 ; PORTB |= 0x14;
0048 88B3 in R24,0x18
004A 8461 ori R24,20
004C 88BB out 0x18,R24
004E .dbline 91
004E ; DDRD |= 0x30;
004E 81B3 in R24,0x11
0050 8063 ori R24,48
0052 81BB out 0x11,R24
0054 .dbline 92
0054 ; PORTD |= 0x30;
0054 82B3 in R24,0x12
0056 8063 ori R24,48
0058 82BB out 0x12,R24
005A .dbline 93
005A ; TCCR1A = 0xA3;
005A 83EA ldi R24,163
005C 8FBD out 0x2f,R24
005E .dbline 94
005E ; TCCR1B = 0x0A;
005E 8AE0 ldi R24,10
0060 8EBD out 0x2e,R24
0062 .dbline 95
0062 ; OCR1A = 0;
0062 2224 clr R2
0064 3324 clr R3
0066 3BBC out 0x2b,R3
0068 2ABC out 0x2a,R2
006A .dbline 96
006A ; OCR1B = 0;
006A 39BC out 0x29,R3
006C 28BC out 0x28,R2
006E .dbline -2
006E L8:
006E .dbline 0 ; func end
006E 0895 ret
0070 .dbend
0070 .dbfunc e uart_init _uart_init fV
0070 ; baud -> R10,R11
.even
0070 _uart_init::
0070 0E940000 xcall push_gset3
0074 5801 movw R10,R16
0076 .dbline -1
0076 .dbline 111
0076 ; }
0076 ;
0076 ;
0076 ; ////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0076 ;
0076 ;
0076 ; //=============================================================
0076 ; // 函数名:void uart_init(unsigned int baud)
0076 ; // 功能: 异步串行通信初始化
0076 ; // 参数: unsigned int baud 设置通信波特率
0076 ; // 返回值: none
0076 ; // 使用方法:uart_init(19200);
0076 ; //=============================================================
0076 ; void uart_init(unsigned int baud)
0076 ; {
0076 .dbline 112
0076 ; UCSRB=0x00;
0076 2224 clr R2
0078 2AB8 out 0xa,R2
007A .dbline 113
007A ; UCSRA=0x00; //控制寄存器清零
007A 2BB8 out 0xb,R2
007C .dbline 114
007C ; UCSRC=(1<<URSEL)|(0<<UPM0)|(3<<UCSZ0); //选择UCSRC,异步模式,禁止校验,1位停止位,8位数据位
007C 86E8 ldi R24,134
007E 80BD out 0x20,R24
0080 .dbline 115
0080 ; baud=mclk/16/baud-1 ; //波特率最大为65K
0080 1501 movw R2,R10
0082 4424 clr R4
0084 5524 clr R5
0086 40E2 ldi R20,32
0088 51EA ldi R21,161
008A 67E0 ldi R22,7
008C 70E0 ldi R23,0
008E 5A92 st -y,R5
0090 4A92 st -y,R4
0092 3A92 st -y,R3
0094 2A92 st -y,R2
0096 8A01 movw R16,R20
0098 9B01 movw R18,R22
009A 0E940000 xcall div32s
009E 41E0 ldi R20,1
00A0 50E0 ldi R21,0
00A2 60E0 ldi R22,0
00A4 70E0 ldi R23,0
00A6 1801 movw R2,R16
00A8 2901 movw R4,R18
00AA 241A sub R2,R20
00AC 350A sbc R3,R21
00AE 460A sbc R4,R22
00B0 570A sbc R5,R23
00B2 5101 movw R10,R2
00B4 .dbline 116
00B4 ; UBRRL=baud;
00B4 29B8 out 0x9,R2
00B6 .dbline 117
00B6 ; UBRRH=baud>>8; //设置波特率
00B6 232C mov R2,R3
00B8 3324 clr R3
00BA 20BC out 0x20,R2
00BC .dbline 118
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -