Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

Back
Top