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

receiving binary data thru the rs232

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



Joined: 21 Jan 2004
Posts: 15
Location: Argentina

View user's profile Send private message

receiving binary data thru the rs232
PostPosted: Mon Jul 26, 2004 12:45 pm     Reply with quote

I'm having troubles to get binary data thru the RS232.
Data entering the port may be any value from 0 to 255 (not only ascii chars). I need to store that data, then get it back and finally output it to an OUTPUT_PIN at a different rate.

I'm wondering if getc() is the right function for that or if it only works within the simbol's range.

data received from the port could be defined as char or as unsigned in the same way?
I'm using 16F628, CCS PCM v3.180.
SherpaDoug



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

View user's profile Send private message

PostPosted: Mon Jul 26, 2004 1:14 pm     Reply with quote

Getc() should work fine. Either an unsigned int or a char will hold any byte.
_________________
The search for better is endless. Instead simply find very good and get the job done.
rnielsen



Joined: 23 Sep 2003
Posts: 852
Location: Utah

View user's profile Send private message

PostPosted: Mon Jul 26, 2004 1:15 pm     Reply with quote

From what I know, RS232 sends data in the form of ASCII text. The PIC will most likely receive it as text characters as well. You could use atoi() to convert it, and store it, to a hex number (int8) and then, later, push the individual bits out to a port pin.

Remember, that a Text '1' is a hex 0x31 whereas a Number '1' is 0x01. A Text '21' is a hex 0x32, 0x31 (two bytes) whereas the Number '21' is 0x15 (one byte). The atoi() function will convert this for you.

Ronald
Mark



Joined: 07 Sep 2003
Posts: 2838
Location: Atlanta, GA

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

PostPosted: Mon Jul 26, 2004 1:45 pm     Reply with quote

Quote:
From what I know, RS232 sends data in the form of ASCII text. The PIC will most likely receive it as text characters as well.


This is an incorrect statement. It sends it as a data byte. It is up to the programmer to know how the data is being sent and how to interpret it. Otherwise, it would be quite difficult to do binary file transfers via RS232!
rwyoung



Joined: 12 Nov 2003
Posts: 563
Location: Lawrence, KS USA

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

PostPosted: Mon Jul 26, 2004 1:58 pm     Reply with quote

rnielsen wrote:
From what I know, RS232 sends data in the form of ASCII text.
Ronald


A byte is a byte is a byte. It is how you interpret the data that makes the difference.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!
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