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

10bit data transmission on PIC?

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



Joined: 02 Jun 2010
Posts: 74

View user's profile Send private message

10bit data transmission on PIC?
PostPosted: Fri Nov 30, 2012 3:00 am     Reply with quote

Hi, is there any ways to send 10 bit data??

I know that modbus spec only states three modes(odd/even with 1 stop bit or no parity with 2 stop bits).

However, on most modbus slave devices, they offer parity option independent from stop bit option.

I can implement odd/even parity with 1 stop bit(9 bit data + 1 stop bit), no parity with 2 stop bit(8 bit data + 1 fixed data + 1 stop bit), or no parity with 1 stop bit(8bit data + 1 stop bit).

However, If I were to implement odd/even parity with 2 stop bits, what should I do??
Is it even possible?

Do the other vendors "actually" support this mode??
RF_Developer



Joined: 07 Feb 2011
Posts: 839

View user's profile Send private message

PostPosted: Fri Nov 30, 2012 5:03 am     Reply with quote

I'm confused... I think you are confused too.

Modbus must use Modbus standard data formats. Modbus RTU and ASCII are generally carried on RS485 physical link that use the "RS232" style asynchronous serial data format.

I don't think "odd/even parity with 2 stop bits" is possible within Modbus.

Some history (somewhat simplified to give the flavour of how things started/developed):

Async serial data is quite flexible and has used a number of variations over the years some now effectively obsolete. All async serial formats have one start bit - fixed "mark" bit to distinguish new data from the "space" quiescent state of the line. Then comes from 5 to 8 (maybe 9) data bits. At the time teleprinters codes, such as Baudot, ASCII and EBCDIC, were 5, 7 and 8 bits respectively. ASCII has come down to us today, and many think of it as an eight bit code represented by C's char data type, but in fact it is a The concept of a parity bit is these days somewhat obsolete. It was orginally a simple check bit to detect some errors in the data bits when async data was carried over poor quality, e.g. teleprinter, lines.

These days it is common to think of parity, if we think of parity at all as most commonly its simply not used, as simply being one of the data bits. Practically all IC UARTS will automatically generate and check parity if required. If you want to send a full 9 bits of data, you may have trouble. Sending 8 with UART generated parity as the ninth is OK, sending an arbitary 9 bits of data is much harder.

After the data came one or more stop bits, again fixed at "mark" as with the start bit. Early devices, most notably the near ubiquitous Teletype ASR33, often required two stop bits as their mechanical decoding needed a little extra guaranteed time between characters to do their thing. Some time 1 1/2 stop bits were specified, but I don't think many current UARTS support that.

The term "ten bit format" sometimes crops up in async data as the near universal standard today, and for the past 20 years or more, has been for one start bit, eight data bits with no parity, and one stop bit: ten bits in all. It may be that this is what you are referring to. There are still only 8 usable data bits. the other two are necessary "overhead".

Modbus:

Modbus RTU runs as one start bit, eight data bits, a even parity bit and one stop bit (sometimes odd parity, sometimes no parity and two stop bits): always eleven in all - the maximum most UARTS will allow. However, Modbus is essentially a 16 bit protocol at its heart, many things requiring two eleven bit data frames. None have twelve bits, such as your "9 data plus parity plus one stop bit" would need. "No parity with 2 stop bits" is NOT "8bit data + 1 fixed data + 1 stop bit" it is ""8bit data + 2 stop bits", i.e. an extended stop bit. In Modbus, there is always and only 8 bits of usable data. The standard only allows two stop bits in the case of no parity being used, or effectively fixed parity bit at "1".

To send ten bit data on Modbus, you would simply send it as a sixteen bit data type and ignore six bits.

RF Developer
Ttelmah



Joined: 11 Mar 2010
Posts: 19368

View user's profile Send private message

PostPosted: Fri Nov 30, 2012 5:03 am     Reply with quote

Dealing only with the hardware UART.
The number of stop bits doesn't matter. The hardware generates one stop, and an extra stop is just a matter of adding a delay. The stop bit is just guaranteeing that the signal will go idle for one bit time. Sending more is just a matter of pausing. The line is idle, so if you pause you are just sending more stops....
Then, the PIC hardware UART can send 9bits maximum. You can use the 9th bit for parity if you want, but if you do, then you have to calculate this yourself, and can then only have 8bit data.
As far as receiving is concerned, once the line switches to the idle level, you can have a hundred idle times if wanted....

Best Wishes
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