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

PIC serial output with 16bit?

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



Joined: 10 Sep 2003
Posts: 60

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger ICQ Number

PIC serial output with 16bit?
PostPosted: Tue Jan 04, 2005 10:24 am     Reply with quote

Is that possible to send 16bit via serial port with 1 time sending command?
Or we have to send it in 2 sending commands?

What's about 10bits?

Thanks...


Regards: Einly
_________________
Einly
ckielstra



Joined: 18 Mar 2004
Posts: 3680
Location: The Netherlands

View user's profile Send private message

PostPosted: Tue Jan 04, 2005 10:41 am     Reply with quote

What about: fprintf("%ld", value)
Ttelmah
Guest







Re: PIC serial output with 16bit?
PostPosted: Tue Jan 04, 2005 10:44 am     Reply with quote

Einly wrote:
Is that possible to send 16bit via serial port with 1 time sending command?
Or we have to send it in 2 sending commands?

What's about 10bits?

Thanks...


Regards: Einly

No.
The UART in the PIC, only supports 8/9 bit transmission/reception. Even using two commands, you will get a stop bit after each byte. Obviously you can generate your own 'wrapper' function, to send a 16bit value, but it'll still result in two transfers. It is important to realise, that it is the word length, following the start bit, that determines the allowable timing errors between the ends. A system providing 16bit async, given the standard sampling strategy, would require baud timings closer than 2%, to be reliable. This is why most of the standard protocol formats only support 5 to 9 bits for this type of comms. 16bit transfers are common for synchronous comms, but not on asynch.

Best Wishes
rwyoung



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

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

Re: PIC serial output with 16bit?
PostPosted: Tue Jan 04, 2005 1:32 pm     Reply with quote

Einly wrote:
Is that possible to send 16bit via serial port with 1 time sending command?
Or we have to send it in 2 sending commands?

What's about 10bits?

Thanks...


Regards: Einly


Do you mean the asynchrounous serial port as in the UART (USART)?
Or do you mean the synchronous serial port?
Or do you mean the SPI port?
Or do you mean the I2C port (although I seldom here people refer to that as the "serial port")?

(edited, not sure how I managed to send this without finishing...)
In all cases, the built-in hardware (found on some but not all chips) for handling these communications does not have support for more than 8 or 9 bits per "word". Note, my information may be out of date as I'm not familiar with the PIC18 or PIC10 family options.

If you want longer word lengths you will need to write your own code to "bit-bang" the interface and not use the built-in hardware.
_________________
Rob Young
The Screw-Up Fairy may just visit you but he has crashed on my couch for the last month!


Last edited by rwyoung on Wed Jan 05, 2005 8:39 am; edited 1 time in total
jaymiller
Guest







16bit serial
PostPosted: Wed Jan 05, 2005 6:44 am     Reply with quote

I have for several years 'bitbanged' 22 bits without any problems.Used in my remote energy control systems,solves any 'hacker' from attacking or figuring out what I'm doing.
jds-pic



Joined: 17 Sep 2003
Posts: 205

View user's profile Send private message

Re: 16bit serial
PostPosted: Wed Jan 05, 2005 4:21 pm     Reply with quote

jaymiller wrote:
'bitbanged' 22 bits...

yes, as long as the receiving entity can speak the same language.

my assumption is, however, that the original poster is somewhat of a PIC novice and is simply trying to send data collected by a PIC to a PC with the two connected via serial RS232. unfortunately there isn't much of a problem statement to go on, but that's what it appears to be. he's flumuxed because the PIC to PC communications are all byte sized, but he needs the PIC to return a value > 8 bits wide to the PC.

the real question then is whether the PC is running a program of his own design, or a commercial terminal application such as hyperterminal. if the former, the PIC can send two bytes back to back, perhaps prefaced by a preamble indicating the next two bytes are a double, or even "packetized" with a simple PIC-to-PC protocol. then, the PC executable can be modified to glue togther the two data bytes to make a 16bit value, and subsequently convert/massage/display/store as needed. however, if the PC program can not be modified, there must be some work done at the PIC to send the 16bit long data in an ASCII format which can then be simply displayed by the terminal program.

jds-pic
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