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 CCS Technical Support

how to receive longint over usart?

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



Joined: 30 Jul 2007
Posts: 112
Location: Moscow, Russia

View user's profile Send private message

how to receive longint over usart?
PostPosted: Sat Apr 26, 2008 8:51 am     Reply with quote

I have a device that sends a long int value over usart as is. How to receive this value?
Douglas Kennedy



Joined: 07 Sep 2003
Posts: 755
Location: Florida

View user's profile Send private message AIM Address

PostPosted: Sat Apr 26, 2008 9:25 am     Reply with quote

A long int is notation for a whole number. The notation is often expressed as bytes. A long integer could take several several bytes EX 32 bits or 16 bits.
The notation can have the most significant bit sent first or the least significant bit sent first for each byte transmitted. Within the several bytes the order in which they are transmitted could be the most significant byte first or the least significant. You will need to understand the notation for the long integer the sender is using. At the receive end the PIC will accept the transmitted byte into a register the register is moved to a variable with var=getc(); var is declared as int8 type statements. The rotate functions maybe needed to reverse the bit order the PIC has the most significant bit as bit7. When the several bytes are received they may have the same byte size as the CCS compiler notation for integers 16 or 32.
The make16 or make32 will arrange the notation of the number so the PICC compiler will understand it. EX make16(var1,var2)) var1 and var2 are two received bytes but be aware of the most significant byte issue.
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