[serial com (rs232)] 9 bits needed

I am trying to build a rs485 network using microcontrolers Microcontrolers have the hability to recieve 9 bits data. They use this as an 'adress'. If the adresse matches the folowing data (8bits) are read (causing an interrupt) otherwize they are ignored until the next adress. gcc can't be configurated for 9 bits (CS9 doesn't exist) Is there another way to do it?? Many thanks in advances Andre

Reply to
andre
Loading thread data ...

Is it 9 bits with no parity? If so, maybe you could bodge it by fiddling the parity bit for each byte sent.

For example:

101010100 = 10101010 + 0 parity (set parity to even before sending this byte) 101010101 = 10101010 + 1 parity (set parity to odd before sending this byte)
Reply to
Dom

And when receiving you can set the receiver for 8 bits + parity (odd or even) with PARMRK (i.e. characters with bad parity are not discarded but marked in the datastream), then calculate the parity of the 8 bits and combine it with the "parity error" indication to know what the 9th bit must have been.

Reply to
Rob

bitfields?

#include #include int main(int argc, char *argv[], char *env[]){ int i; struct { /*9 bit field*/ unsigned x:9; } y; y.x=500; for (i=0;i

Reply to
colonel_hack

GCC is the compiler - it has nothing to do with serial communication.

On the 8250 family of serial interfaces (in the IBM PC way) have a mode called 'stick parity' where you can send the ninth bit, controlling it with the parity selection. On receive, you can follow the parity error bit. Clumsy, but working.

--

-TV
Reply to
Tauno Voipio

"9 bit" is a hardware feature of the UART. Hardware support is best, unless you "bit-bang" the serial bits totally in software.

It's not a compiler issue. Look at how the Microchip PIC or Atmel AVR do it: it's via control registers and data that are all 8-bit-bytes.

Software bit-banging.

Reply to
Jeff Jonas

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.