i only design the porgram so that only display the first 16 character from USart
so, when more than 16 word is type in hyperterminal, the 16 character remain on LCD.
if(Usart_Data_Ready()==1 & mystat==0)
{ rec=Usart_Read(); mystat=1; }
if(mystat==1)
{
cnt++;
Lcd_Custom_Chr(1,cnt,rec);
mystat=0;
if(cnt>16){ Lcd_Custom_Chr(2,cnt-16,rec);}
if(cnt>32){cnt=1; Lcd_Custom_Cmd(Lcd_First_Row);}
chuaweekok WROTE:i only design the porgram so that only display the first 16 character from USart
so, when more than 16 word is type in hyperterminal, the 16 character remain on LCD.
waiweng83 WROTE:If this is correct, you will just see the random character showing on the LCD because the GPS keeps sending data to the MCU.
while(1)
{
n = 0;;
for(n =0; n <10; n ++)
{
if (Usart_Data_Ready() == 1)
{receive = Usart_Read(); // Copy usart data to receive.
Usart_Write(receive);
cnt++;
}
if (receive == ',' )
{receive = ' '; rec2++; cnt = 0; n = 0;
}
else if ( receive == 'C' )
{receive = ' '; rec1 = 1;
}
else if (receive == '*')
{receive = ' '; rec1 = 0; rec2 = 0; n = 10;
}
else {
receive = ' ';
if( cnt != 0 && rec1 == 1 && rec2 == 3)
{latitude[cnt-1]=Usart_read(); // Copy Usart data to latitude.
}
else if( cnt != 0 && rec1 == 1 && rec2 == 5)
{longitude[cnt-1]=Usart_read(); // Copy Usart data to longitude.
}
else if( cnt != 0 && rec1 == 1 && rec2 == 8)
{course[cnt-1]=Usart_read(); // Copy Usart data to course.
}
}
}
LCDdisplay();
}
}
void LCDdisplay(void)
{
for(cnt1=0; cnt1 < 11; cnt1++)
{ Lcd_Custom_Chr(1,cnt1+7,latitude[cnt1]);
Lcd_Custom_Chr(2,cnt1+6,longitude[cnt1]);
}
if(Usart_Data_Ready()==1 & mystat==0)
{
rec=Usart_Read();
mystat=1;
}
if(mystat==1)
{
cnt++;
Lcd_Custom_Chr(1,cnt,rec);
mystat=0;
if(cnt>16)
{
Lcd_Custom_Chr(2,cnt-16,rec);
}
if(cnt>32)
{
cnt=33;
}
}
Users browsing this forum: No registered users and 4 guests