C18 UART read buffer

Status
Not open for further replies.

eng.hasan.power

New Member
hi everyone,

i want to implement a buffer in C18,,,, and 97j60 controller will be the receiver,,,,,

the transmitter keep sending from 0x41 to 0x48,,,, i want the receiver to detect that and save the block of data in a buffer,,,,,, i made some code, but its not working good,,, it shows the data in order but with a lot of garbage data too.,,,,

Hi =0;
while(!DataRdyUSART());
tempUART[0] = ReadUART();
if (tempUART[0] == 0x41) //start of the data block
{
for( Hi=1; Hi<8; Hi++ ) // start reading to fill the buffer
{
while(!DataRdyUSART());
tempUART[Hi] = ReadUART(); // read the data
while(BusyUART());
{
WriteUART(tempUART[Hi]); // write the data
}
}
}

////
but if there is a better code that would be much better,,,,

Best Regards
Hasan
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…