Joined: 30 Jul 2007 Posts: 112 Location: Moscow, Russia
how to receive longint over usart?
Posted: Sat Apr 26, 2008 8:51 am
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
Posted: Sat Apr 26, 2008 9:25 am
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.
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