📄 gps.lst
字号:
__text_start:
__start:
011A E5CF LDI R28,0x5F
011B E0D8 LDI R29,0x8
011C BFCD OUT 0x3D,R28
011D BFDE OUT 0x3E,R29
011E 51C0 SUBI R28,0x10
011F 40D0 SBCI R29,0
0120 EA0A LDI R16,0xAA
0121 8308 STD Y+0,R16
0122 2400 CLR R0
0123 E6E0 LDI R30,0x60
0124 E0F0 LDI R31,0
0125 E015 LDI R17,5
0126 33E9 CPI R30,0x39
0127 07F1 CPC R31,R17
0128 F011 BEQ 0x012B
0129 9201 ST R0,Z+
012A CFFB RJMP 0x0126
012B 8300 STD Z+0,R16
012C E3E4 LDI R30,0x34
012D E0F2 LDI R31,2
012E E6A0 LDI R26,0x60
012F E0B0 LDI R27,0
0130 E012 LDI R17,2
0131 33E4 CPI R30,0x34
0132 07F1 CPC R31,R17
0133 F021 BEQ 0x0138
0134 95C8 LPM
0135 9631 ADIW R30,1
0136 920D ST R0,X+
0137 CFF9 RJMP 0x0131
0138 940E013B CALL _main
_exit:
013A CFFF RJMP _exit
FILE: E:\Program\gps\main.c
(0001) /*
(0002) ###############################################################################
(0003) Include Part
(0004) ###############################################################################
(0005) */
(0006) #include <iom32v.h> // mega16 register definition file
(0007) #include <lcd.h> // LCD driver file
(0008) #include "def.h" // Type definition file
(0009) #include <macros.h>
(0010) #include <serial.h> //serial port driver file
(0011)
(0012)
(0013) /*
(0014) ##############################################################
(0015) define part
(0016) ##############################################################
(0017) */
(0018) // char rcv_buf[1024];
(0019) char time[10];
(0020) char status;
(0021) char latitude[9];
(0022) char NSind;
(0023) char longtitude[10];
(0024) char EWind;
(0025) char date[6];
(0026)
(0027)
(0028) /*
(0029) ###############################################################################
(0030) Function Prototype Definition Part
(0031) ###############################################################################
(0032) */
(0033) void port_init(void);
(0034) void init_devices(void);
(0035) void GpsDataParse(void);
(0036) void Parse (void);
(0037) //void convert (void);
(0038)
(0039)
(0040)
(0041) /*
(0042) ###############################################################################
(0043) Function Implementation Part
(0044) ###############################################################################
(0045) */
(0046) void main (void)
(0047) {
(0048) int i=0;
_main:
i --> R20
013B 2744 CLR R20
013C 2755 CLR R21
(0049) //initial the MCU
(0050) init_devices();
013D D013 RCALL _init_devices
013E C003 RJMP 0x0142
(0051) while (1)
(0052) {
(0053) // for (i=0;i<3000;i++);
(0054) GpsDataParse(); //get data
013F D01B RCALL _GpsDataParse
(0055) display(); //display
0140 940E028C CALL _display
0142 CFFC RJMP 0x013F
0143 9508 RET
(0056) }
(0057)
(0058) }
(0059)
(0060)
(0061) void port_init(void)
(0062) {
(0063) PORTA = 0x00;
_port_init:
0144 2422 CLR R2
0145 BA2B OUT 0x1B,R2
(0064) DDRA = 0xFC;
0146 EF8C LDI R24,0xFC
0147 BB8A OUT 0x1A,R24
(0065) PORTB = 0x00;
0148 BA28 OUT 0x18,R2
(0066) DDRB = 0x00;
0149 BA27 OUT 0x17,R2
(0067) PORTC = 0x00; //m103 output only
014A BA25 OUT 0x15,R2
(0068) DDRC = 0x83;
014B E883 LDI R24,0x83
014C BB84 OUT 0x14,R24
(0069) PORTD = 0x00;
014D BA22 OUT 0x12,R2
(0070) DDRD = 0x9C;
014E E98C LDI R24,0x9C
014F BB81 OUT 0x11,R24
0150 9508 RET
(0071) }
(0072)
(0073) //call this routine to initialize all peripherals
(0074) void init_devices(void)
(0075) {
(0076) //stop errant interrupts until set up
(0077) CLI(); //disable all interrupts
_init_devices:
0151 94F8 BCLR 7
(0078) port_init();
0152 DFF1 RCALL _port_init
(0079) uart0_init();
0153 940E0207 CALL _uart0_init
(0080)
(0081) MCUCR = 0x00;
0155 2422 CLR R2
0156 BE25 OUT 0x35,R2
(0082) GICR = 0x00;
0157 BE2B OUT 0x3B,R2
(0083) TIMSK = 0x00; //timer interrupt sources
0158 BE29 OUT 0x39,R2
(0084) //all peripherals are now initialized
(0085) SEI();
0159 9478 BSET 7
015A 9508 RET
_GpsDataParse:
head --> Y+0
temp --> R20
015B 940E0726 CALL push_gset1
015D 9723 SBIW R28,3
(0086) }
(0087) void GpsDataParse(void)
(0088) {
(0089) char head[3];
(0090) char temp;
(0091)
(0092) //CLI();
(0093) temp=Read_buf();
015E 940E025C CALL _Read_buf
0160 2F40 MOV R20,R16
0161 C003 RJMP 0x0165
(0094) while (temp != '$')
(0095) temp=Read_buf();
0162 940E025C CALL _Read_buf
0164 2F40 MOV R20,R16
0165 3244 CPI R20,0x24
0166 F7D9 BNE 0x0162
(0096)
(0097) temp=Read_buf();//first and second character are "GPXXX"
0167 940E025C CALL _Read_buf
(0098) temp=Read_buf();
0169 940E025C CALL _Read_buf
016B 2F40 MOV R20,R16
(0099)
(0100) //get the header
(0101) head[0]=Read_buf();
016C 940E025C CALL _Read_buf
016E 8308 STD Y+0,R16
(0102) head[1]=Read_buf();
016F 940E025C CALL _Read_buf
0171 8309 STD Y+1,R16
(0103) head[2]=Read_buf();
0172 940E025C CALL _Read_buf
0174 830A STD Y+2,R16
(0104) if(head[0]=='R' && head[1]=='M' && head[2]=='C')
0175 8188 LDD R24,Y+0
0176 3582 CPI R24,0x52
0177 F431 BNE 0x017E
0178 8189 LDD R24,Y+1
0179 348D CPI R24,0x4D
017A F419 BNE 0x017E
017B 3403 CPI R16,0x43
017C F409 BNE 0x017E
(0105) {
(0106) Parse ();
017D D004 RCALL _Parse
(0107) return ;
017E 9623 ADIW R28,3
017F 940E0729 CALL pop_gset1
0181 9508 RET
_Parse:
i --> R20
temp --> R22
0182 940E0724 CALL push_gset2
(0108) }
(0109) }
(0110)
(0111) /**********************************************************************
(0112) * get information from GPRMC
(0113) *Description: need array to place time,date, latitude,longtitude
(0114) size of the array
(0115) ************************************************************************/
(0116) void Parse (void)
(0117) {
(0118) char temp;
(0119) int i=0;
0184 2744 CLR R20
0185 2755 CLR R21
(0120)
(0121) //read time
(0122) temp=Read_buf();// jump over ','
0186 940E025C CALL _Read_buf
(0123) temp=Read_buf();
0188 940E025C CALL _Read_buf
018A 2F60 MOV R22,R16
018B C00C RJMP 0x0198
(0124) while(i<10)
(0125) {
(0126) time[i++]=temp;
018C 011A MOVW R2,R20
018D 5F4F SUBI R20,0xFF
018E 4F5F SBCI R21,0xFF
018F E78C LDI R24,0x7C
0190 E090 LDI R25,0
0191 01F1 MOVW R30,R2
0192 0FE8 ADD R30,R24
0193 1FF9 ADC R31,R25
0194 8360 STD Z+0,R22
(0127) temp=Read_buf();
0195 940E025C CALL _Read_buf
0197 2F60 MOV R22,R16
0198 304A CPI R20,0xA
0199 E0E0 LDI R30,0
019A 075E CPC R21,R30
019B F384 BLT 0x018C
(0128) }
(0129)
(0130) // convert ();
(0131) //read status
(0132) status=Read_buf();
019C 940E025C CALL _Read_buf
019E 9300007B STS status,R16
(0133) if (status=='V')
01A0 3506 CPI R16,0x56
01A1 F409 BNE 0x01A3
(0134) return;
01A2 C061 RJMP 0x0204
(0135)
(0136) //read latitude
(0137) temp=Read_buf();//read the ','
01A3 940E025C CALL _Read_buf
01A5 2F60 MOV R22,R16
(0138) i=0;
01A6 2744 CLR R20
01A7 2755 CLR R21
01A8 C00F RJMP 0x01B8
(0139) while(i<9)
(0140) latitude[i++]=Read_buf();
01A9 011A MOVW R2,R20
01AA 5F4F SUBI R20,0xFF
01AB 4F5F SBCI R21,0xFF
01AC 922F PUSH R2
01AD 923F PUSH R3
01AE 940E025C CALL _Read_buf
01B0 903F POP R3
01B1 902F POP R2
01B2 E782 LDI R24,0x72
01B3 E090 LDI R25,0
01B4 01F1 MOVW R30,R2
01B5 0FE8 ADD R30,R24
01B6 1FF9 ADC R31,R25
01B7 8300 STD Z+0,R16
01B8 3049 CPI R20,0x9
01B9 E0E0 LDI R30,0
01BA 075E CPC R21,R30
01BB F36C BLT 0x01A9
(0141)
(0142) //read NSindicator
(0143) temp=Read_buf();//read the ','
01BC 940E025C CALL _Read_buf
(0144) NSind=Read_buf();
01BE 940E025C CALL _Read_buf
01C0 93000071 STS NSind,R16
(0145) temp=Read_buf();//read the ','
01C2 940E025C CALL _Read_buf
01C4 2F60 MOV R22,R16
(0146)
(0147) //read longtitude
(0148) i=0;
01C5 2744 CLR R20
01C6 2755 CLR R21
01C7 C00F RJMP 0x01D7
(0149) while(i<10)
(0150) longtitude[i++]=Read_buf();
01C8 011A MOVW R2,R20
01C9 5F4F SUBI R20,0xFF
01CA 4F5F SBCI R21,0xFF
01CB 922F PUSH R2
01CC 923F PUSH R3
01CD 940E025C CALL _Read_buf
01CF 903F POP R3
01D0 902F POP R2
01D1 E687 LDI R24,0x67
01D2 E090 LDI R25,0
01D3 01F1 MOVW R30,R2
01D4 0FE8 ADD R30,R24
01D5 1FF9 ADC R31,R25
01D6 8300 STD Z+0,R16
01D7 304A CPI R20,0xA
01D8 E0E0 LDI R30,0
01D9 075E CPC R21,R30
01DA F36C BLT 0x01C8
(0151)
(0152) //read EWindicator
(0153) temp=Read_buf();//read the ','
01DB 940E025C CALL _Read_buf
01DD 2F60 MOV R22,R16
(0154) EWind=Read_buf();
01DE 940E025C CALL _Read_buf
01E0 93000066 STS EWind,R16
(0155) i=0;
01E2 2744 CLR R20
01E3 2755 CLR R21
01E4 C00B RJMP 0x01F0
(0156) while (i<3)
(0157) {
(0158) temp=Read_buf();//read the ','
01E5 940E025C CALL _Read_buf
01E7 2F60 MOV R22,R16
01E8 C003 RJMP 0x01EC
(0159) while (temp!=',')
(0160) temp=Read_buf();
01E9 940E025C CALL _Read_buf
01EB 2F60 MOV R22,R16
01EC 326C CPI R22,0x2C
01ED F7D9 BNE 0x01E9
(0161) i++;
01EE 5F4F SUBI R20,0xFF
01EF 4F5F SBCI R21,0xFF
01F0 3043 CPI R20,3
01F1 E0E0 LDI R30,0
01F2 075E CPC R21,R30
01F3 F38C BLT 0x01E5
(0162) }
(0163) for (i=0;i<6;i++)
01F4 2744 CLR R20
01F5 2755 CLR R21
(0164) {
(0165) date[i]=Read_buf();
01F6 940E025C CALL _Read_buf
01F8 E680 LDI R24,0x60
01F9 E090 LDI R25,0
01FA 01FA MOVW R30,R20
01FB 0FE8 ADD R30,R24
01FC 1FF9 ADC R31,R25
01FD 8300 STD Z+0,R16
01FE 5F4F SUBI R20,0xFF
01FF 4F5F SBCI R21,0xFF
0200 3046 CPI R20,6
0201 E0E0 LDI R30,0
0202 075E CPC R21,R30
0203 F394 BLT 0x01F6
0204 940E0718 CALL pop_gset2
0206 9508 RET
FILE: E:\Program\gps\serial.c
(0001) //ICC-AVR application builder : 2006-5-8 20:10:07
(0002) // Target : M16
(0003) // Crystal: 8Mhz
(0004)
(0005) #include <iom32v.h>
(0006) #include <macros.h>
(0007) #include <serial.h>
(0008)
(0009) #define max 1024
(0010)
(0011) /* Static Variables */
(0012) int count;
(0013) char rcv_buf[max];
(0014) int UART_wp;//write data to receive buffer
(0015) int read_pt;//read pointer: read data from receive buffer
(0016)
(0017)
(0018) //UART0 initialize
(0019) // desired baud rate: 4800
(0020) // actual: baud rate:4800 (0.0%)
(0021) // char size: 8 bit
(0022) // parity: Disabled
(0023) void uart0_init(void)
(0024) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -