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

rs232 data transmit from PC

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



Joined: 26 Jan 2008
Posts: 15

View user's profile Send private message

rs232 data transmit from PC
PostPosted: Sat Feb 16, 2008 3:20 am     Reply with quote

hi,i'm using PIC16f877a and i would like it to receive integer data where transmitted from PC.but i cant find any command that will get integer.i just can find the command of getchar which is get characters...may somebody help me in this pro? my aim is to receive transmitted integer from PC,the integer is from 0-100...
thx very much for ur help.. Smile
arunb



Joined: 08 Sep 2003
Posts: 492
Location: India

View user's profile Send private message Send e-mail

RE:
PostPosted: Sat Feb 16, 2008 5:20 am     Reply with quote

Hi,

You can use the getc() function to get the data from the PC.

If you need to send integer data then send the ASCII code of the integer.

for example in VB you would do this as chr$(n) where n is the integer, of course you cannot exceed 255.

For large values break up the data into 2 byte format and send each byte individually, the PIC can then receive the bytes and re-construct the data using make16.

Alternatively you can send the integer as a string, "1", "2" etc.
But the PIC will receive the data as the equivalent ASCII code, for example "1" will be 49, 2 will be 50, to get the integer value subtract from 48..

hope this helps....

thanks
arunb
SherpaDoug



Joined: 07 Sep 2003
Posts: 1640
Location: Cape Cod Mass USA

View user's profile Send private message

PostPosted: Sat Feb 16, 2008 10:08 am     Reply with quote

In a nutshell, a PC RS232 port can only send data byte at a time. Getc() reads bytes. How to interpret those byte once you get then into the PIC is up to you. Beware of Big Endian vs. Little Endian problems between computers.
_________________
The search for better is endless. Instead simply find very good and get the job done.
casandralam



Joined: 26 Jan 2008
Posts: 15

View user's profile Send private message

thanks you very much
PostPosted: Sun Feb 17, 2008 5:59 pm     Reply with quote

thanks you very much..
both of your reply is very useful for me
i would like to try it on my PIC
thanks.. Smile
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