完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
PIC-18F420,MPLAB,XC8这是我的问题。制作一个GPS/GSM项目发送短信到我的手机。GPS工作和显示,GSM还没有连接,但正在获取代码。看到我的范围结果,3个脉冲是在WHER()内启动的,我不明白为什么它只循环3次而不是连续。我出了点毛病,认不出来了。我之前贴了一个类似的帖子,并纠正了一些问题,但我现在在这里。我已经看过我的UART,TX和RX设置,没有看到任何错误。GPS单元本身不停地工作(不是问题)。计时问题? 以上来自于百度翻译 以下为原文 PIC-18f4520, mplab, xc8 Here's my issue. Making a gps/gsm project to send SMS to my cell. Gps works and displays, Gsm is not connected yet, but getting code. See my scope results, 3 pulses are upon starting up within the While(), I don't understand why it's only cycling 3 times and not continually. I have something wrong and cannot spot it. I posted a similiar post before and have since corrected some issues, but this where I'm at. I've looked through my UART, TX and RX settings and don't see anything wrong. The gps unit itself works non-stop (not the issue). Timing issue? // GPS function using PIC18f4520....Team Unicorn #define _XTAL_FREQ 8000000 // subject to change #include #include #include #include #include #pragma config BOREN=ON,LVP=OFF,CPD=OFF,OSC=INTIO7,WDT=OFF, unsigned char TIME[6],LATITUDE[9],LAT_Dir[1],LONGITUDE[10],LON_Dir[1],buffer[7],gps_header[]="GPGGA,"; // for GPS string array, $GPGGA, char UART_Init(const long int baudrate),UART_Read(),UART_Data_Ready();; void LCDinit(), LCDcmd(int unicorn), LCDstring(char *unicorn), LCDdata(int unicorn); // LCD stuff void SMS_Emergency(void), GPS_Emergency(void), SMS(void), GPS(void); void Delay_Ms(unsigned int delay); void UART_Data(char data), UART_String(char *text); void LCD_OUTPUT(); char UART_Init(const long int baudrate){ TRISC6=0; TRISC7=1; TXSTA=0b00100010, RCSTA=0b10010000; SPBRG = (_XTAL_FREQ - baudrate*64)/(baudrate*64); // 8M hz, 9600 bps TXIF=RCIF=0;} int main(void){ OSCCON = 0x76; // Sets internal oscillator to 8MHz TRISA = 0b11111100; // LED A0 (r),A1 (g) TRISB = 0b11111111; // Interrupts B0,B1 TRISD = 0b01100000; // LCD: E-D7,RS-D4, Data-3:0 Delay_Ms(10), LCDinit(); LCDcmd(0x80),LCDstring(" TEAM UNICORN "); UART_Init(9600); while(1){ GPS(); SMS(); Delay_Ms(100); // for 15 secs it's about delay(1300) }} char UART_Read(){ while(!RCIF); // while reception not complete (p215) return RCREG;} // 8-bit received data void UART_Data(char data){ while (!TRMT); // Wait for empty transmit buffer (p204) TXREG = data;} // EUSART Transmit Register (loading data into) void UART_String(char *text){ // send out data characters int i; for(i=0;text!=' |