waiweng83 WROTE:Is the UART of the PIC having overrun error?
Is the UART of the PIC having overrun error?
i dont understand what is the overrun error?
how to check it?
waiweng83 WROTE:Is the UART of the PIC having overrun error?
Is the UART of the PIC having overrun error?
waiweng83 WROTE:To solve this problem, maybe you can save the received data in a buffer, let say you save the first 32 bytes of data in an array first. After that, you only display the character on the LCD
int cnt = 0;
int cnt1 = 0;
int mystat = 0;
char rec[32];
void LCDdisplay(char data, char data);
void main()
{
USART_init(4800);
TRISB = 0; PORTB = 0X00;
TRISC = 0x80; PORTC = 0x00;
TRISD = 0; PORTD = 0X00;
Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTB,4,6,5);
lCD_Custom_Cmd(Lcd_CURSOR_OFF);
while(1)
{
if(Usart_Data_Ready()==1)
{ rec[cnt]=Usart_Read();
cnt++; }
if(cnt > 33){
for(cnt1=0; cnt1 < 33; cnt1++)
{ Lcd_Custom_Chr(1,cnt1+1,rec[cnt1]);
if(cnt1>16){Lcd_Custom_Chr(2,cnt1-16,rec[cnt1]);}
if(cnt1>32){ cnt=33;} }
}
} }
int cnt = 0;
int cnt1 = 0;
int rec = 0;
int rec1 = 0;
int rec2 = 0;
int cnt2 = 0;
char NMEA[50];
char receive = ' ';
char latitude[] = "xxxx.xxxx";
char longitude[] = "xxxxx.xxxx";
void LCDdisplay(void);
void main()
{
USART_init(4800);
TRISB = 0x00; PORTB = 0X00; // Port b is output and initialize port b
TRISC = 0x80; PORTC = 0x00;
TRISD = 0x00; PORTD = 0X00; // Port d is output and initialize port d
Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTB,4,6,5); // Initialize Lcd port
lCD_Custom_Cmd(Lcd_CURSOR_OFF);
while(1)
{
receive = ' ';
while(receive != '*')
{if (Usart_Data_Ready() == 1)
{receive = Usart_Read();
cnt++;
if (receive == ',' )
{rec2++; cnt = 0;
}
else if (receive == '$' )
{rec2 = 0;
}
if (rec2 == 3 && cnt != 0)
{latitude[cnt-1]=Usart_read();
}
else if (rec2 ==5 && cnt!= 0)
{longitude[cnt-1]=Usart_read();
}
}
}
LCDdisplay();
}
}
void LCDdisplay(void)
{
Lcd_Custom_Out(1,1,"lat : "); // Output to Lcd.
Lcd_Custom_Out(2,1,"long: ");
Lcd_Custom_Out(1,16,"N"); // Output to Lcd.
Lcd_Custom_Out(2,16,"E");
for(cnt1=0; cnt1 < 11; cnt1++)
{ Lcd_Custom_Chr(1,cnt1+7,latitude[cnt1]);
Lcd_Custom_Chr(2,cnt1+6,longitude[cnt1]);
}
}
chuaweekok WROTE:here is the code to output latitude and longitude to LCD 4 bit
before that, the GPS has to set using miniGPS
baudrate to 4800, NMEA output only RMC is 1, other 0
chuaweekok WROTE:here is the code to output latitude and longitude to LCD 4 bit
before that, the GPS has to set using miniGPS
baudrate to 4800, NMEA output only RMC is 1, other 0
- CODE: SELECT_ALL_CODE
int cnt = 0;
int cnt1 = 0;
int rec = 0;
int rec1 = 0;
int rec2 = 0;
int cnt2 = 0;
char NMEA[50];
char receive = ' ';
char latitude[] = "xxxx.xxxx";
char longitude[] = "xxxxx.xxxx";
void LCDdisplay(void);
void main()
{
USART_init(4800);
TRISB = 0x00; PORTB = 0X00; // Port b is output and initialize port b
TRISC = 0x80; PORTC = 0x00;
TRISD = 0x00; PORTD = 0X00; // Port d is output and initialize port d
Lcd_Custom_Config(&PORTD,7,6,5,4,&PORTB,4,6,5); // Initialize Lcd port
lCD_Custom_Cmd(Lcd_CURSOR_OFF);
while(1)
{
receive = ' ';
while(receive != '*')
{if (Usart_Data_Ready() == 1)
{receive = Usart_Read();
cnt++;
if (receive == ',' )
{rec2++; cnt = 0;
}
else if (receive == '$' )
{rec2 = 0;
}
if (rec2 == 3 && cnt != 0)
{latitude[cnt-1]=Usart_read();
}
else if (rec2 ==5 && cnt!= 0)
{longitude[cnt-1]=Usart_read();
}
}
}
LCDdisplay();
}
}
void LCDdisplay(void)
{
Lcd_Custom_Out(1,1,"lat : "); // Output to Lcd.
Lcd_Custom_Out(2,1,"long: ");
Lcd_Custom_Out(1,16,"N"); // Output to Lcd.
Lcd_Custom_Out(2,16,"E");
for(cnt1=0; cnt1 < 11; cnt1++)
{ Lcd_Custom_Chr(1,cnt1+7,latitude[cnt1]);
Lcd_Custom_Chr(2,cnt1+6,longitude[cnt1]);
}
}
Users browsing this forum: No registered users and 4 guests