Reply
Posts: 21
Registered: ‎05-03-2013

Is there any limit on till what time we can send the data through Serial UART

Hello friends,
I am using C8051F312 and I want to send data serially and see it on the hyper terminal. It operates well till the first one hour but later on it slows down the rate. I am obtaining data serially from GPS at a baud rate of 9600bps and sending it at a bit rate of 19200bps. If I try to send the data at a baud rate of 9600 or lower the data is missed at some intervals can anyone please suggest why this is happening. Data which is been obtained serially from GPS comes for a long period of time even for hours then why cant we transmit it
Posts: 2,027
Registered: ‎07-14-2007

Re: Is there any limit on till what time we can send the data through Serial UART

Hi mandar,

you described the problem, but additional posting the code would be helpful, so that we can see what happens.
Please don't forget to post the code between the code tags.

Regards,

Scotty
Posts: 8,134
Registered: ‎08-13-2003

Re: Is there any limit on till what time we can send the data through Serial UART

mandar2589

keep your UART questions in one thread
erik
Posts: 21
Registered: ‎05-03-2013

Re: Is there any limit on till what time we can send the data through Serial UART

Hi Scotty,
The Code is given below
Code:

void SerialConfig_Receive()
{
TH1 = 0xD0; //for a baud rate of 9600bps
CKCON = 0x00; //T1M = 0; SCA1:0 = 0x00
TL1 = TH1; // init Timer1
TMOD &= ~0xf0; // TMOD: timer 1 in 8-bit autoreload
TMOD |= 0x20;
TR1 = 1; // START Timer1
}

void SerialConfig_Transmit()
{
TH1 = 0xB8; // for a baud rate of 19200bps
CKCON = 0x01; //T1M = 0 SCA1:0 = 0x01
TL1 = TH1; // init Timer1
TMOD &= ~0xf0; // TMOD: timer 1 in 8-bit autoreload
TMOD |= 0x20;
TR1 = 1; // START Timer1
}

void UART0_ISR() interrupt 4 // using 1{
{
int k;
if(TI0)
{
TI0 = 0;

SerialConfig_Transmit();
for(k = 12;k {
SBUF0 = Tx_Data_Array[k];
while(!TI0);
TI0 = 0;
}
SBUF0 = '
';
while(!TI0);
TI0 = 0;

SBUF0 = '
';
while(!TI0);
TI0 = 0;

EA = 0;
ES0 = 0;
EA = 1;
SerialConfig_Receive();
}
if(RI0)
{
RI0 = 0;
if(GGA_count < GPS_GPGGA_LEN)
{
if(SBUF0 == GGA[GGA_count])
{
GPS_string[GPScount++] = gga_id_lowercase[GGA_count];
++GGA_count;
}
else
{
GPScount = 0;
GGA_count = 0;
GPS_comma_count = 0;
}
}

else
{
if(SBUF0 == ',')
{
++GPS_comma_count;

if(GPS_comma_count<6)
{
GPS_string[GPScount++] = indicator_array[GPS_comma_count-1];
GGA_data_accept_flag = 1;
}
if((GPS_comma_count==6)) // || (GPS_comma_count==8) || (GPS_comma_count==10))
{
GGA_data_accept_flag = 0;
}
if((GPS_comma_count==7) || (GPS_comma_count==9))
{
GPS_string[GPScount++] = indicator_array[GPS_comma_count-1];
GGA_data_accept_flag = 1;
}
if((GPS_comma_count==8))
{
GGA_data_accept_flag = 0;
}
if(GPS_comma_count == FOOTER)
{
GGA_data_accept_flag = 0;
GPS_string[GPScount] = '\0';
EA = 0;
REN0 = 0; // No more GPS data Receive
ES0 = 0; // Disable serial Interrupt
EA = 1;

GPS_acq_complete = 1;//o come out of 1.5secs delay
serial_tx_flag = 1;
GPS_prev_count = GPScount;
strcpy(GPS_prev_string,GPS_string);

GGA_data_accept_flag = 0;
GPS_comma_count = 0;
GGA_count = 0;
return;
}
}
else
{
if(GGA_data_accept_flag)
GPS_string[GPScount++] = SBUF0;

if(SBUF0 == 'E') // to avoid clashing with Honeywell Indicator 'E' for External temp.
GPS_string[GPScount-1] = 'e';

if(SBUF0 == 'N')
GPS_string[GPScount-1] = 'n';

if(SBUF0 == 'S') // to avoid clashing with Honeywell Indicator 'E' for External temp.
GPS_string[GPScount-1] = 's';

if(SBUF0 == 'W')
GPS_string[GPScount-1] = 'w';

}

} // End of else

} // End of if(RI0)
}//End of UART0_ISR()
<a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> jmg
Posts: 1,175
Registered: ‎04-27-2004

Re: Is there any limit on till what time we can send the data through Serial UART

Interrupts are usually kept very short, and nimble.
Handle flags, and write data to a FIFO array, and do very little else.

Certainly, do NOT do this, inside an interrupt.
Code:

for(k = 12;k {
SBUF0 = Tx_Data_Array[k];
while(!TI0);
TI0 = 0;
}



Quote:

If I try to send the data at a baud rate of 9600 or lower the data is missed at some intervals can anyone please suggest why this is happening.


Usually GPS strings are short, with long gaps between messages.
So you do have to finish sending before the next string is ready to send, but usually that is not hard to do.

Change of Baud rate on the fly, has its own issues and should be avoided unless you really know what you are doing.
Posts: 8,134
Registered: ‎08-13-2003

Re: Is there any limit on till what time we can send the data through Serial UART

Code:
void UART0_ISR() interrupt 4  // using 1{
{
int k;
if(TI0)
{
TI0 = 0;

[color:#CC0000]SerialConfig_Transmit();[/color]


do not configure inside an ISR configure ONLY at top of main
erik
Posts: 8,134
Registered: ‎08-13-2003

Re: Is there any limit on till what time we can send the data through Serial UART

something does not make sense
you state 'I am obtaining data serially from GPS at a baud rate of 9600bps and sending it at a bit rate of 19200bps' and your code only refer to one UART.
erik
<a href="http://community.silabs.com/t5/Welcome-and-Announcements/Community-Ranking-System-and-Recognition-Program/m-p/140490#U140490"><font color="#000000"><font size="2">Hero</font></font> </a> jmg
Posts: 1,175
Registered: ‎04-27-2004

Re: Is there any limit on till what time we can send the data through Serial UART

Originally Posted By: erikm
something does not make sense
you state 'I am obtaining data serially from GPS at a baud rate of 9600bps and sending it at a bit rate of 19200bps' and your code only refer to one UART.


Yes, he is changing Baud on the fly. Not really a good idea for novices, as you are now very much half duplex.
If you really had to do this, a device with 2 uarts would be a better choice, or a soft UART as 9600 is not fast.
Posts: 21
Registered: ‎05-03-2013

Re: Is there any limit on till what time we can send the data through Serial UART

Hello,
can i send the data from the main instead of the ISR and the code in the receive ISR is shifted to the main but please suggest how to send one byte at a time from the ISR, the data is stored in an array

regards
Highlighted
Posts: 8,134
Registered: ‎08-13-2003

Re: Is there any limit on till what time we can send the data through Serial UART

AGAIN are you trying to do both from the same UART?
you can NOT have multipoint RS-232
erik