CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Developing frames/packets using serial data (bytes)

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
samurai



Joined: 15 Apr 2008
Posts: 1

View user's profile Send private message

Developing frames/packets using serial data (bytes)
PostPosted: Thu May 22, 2008 4:00 am     Reply with quote

Hi guys,

I'm using PIC16F877A for a LED display.
The PIC communicates with a PC using the serial port.
Here PC will send binary data (ex: data that should be displayed in the LED display).

I'm thinking of below scenario to send data from PC to PIC.

PC send below frame to PIC.

StartFlag-DataLength-Data-StopFlag
| | | |
1byte 2bytes xbyte 1byte

someone pls advice me on how to do this.

reg.
RLScott



Joined: 10 Jul 2007
Posts: 465

View user's profile Send private message

Re: Developing frames/packets using serial data (bytes)
PostPosted: Thu May 22, 2008 5:10 am     Reply with quote

Whenever you have a connection that could be broken, it is good to have a protocol in place to re-establish synchronization in the event that it is lost. Therefore I suggest that you make your StartFlag unique - so that it can never appear in the DataLength, Data, or StopFlag. That means your DataLength would not be straight binary, which could attain any value, but rather it would be encoded in some way to avoid the StartFlag value. The same consideration should be followed for the Data field. One way to do this would be to send 4 bits in each character. Or, if you want to be more efficient, send 7 bits in each character and use bit 7 to indicate that the character is a StartFlag or StopFlag.

Robert Scott
Real-Time Specialties
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group