View previous topic :: View next topic |
Author |
Message |
chaphill
Joined: 07 May 2019 Posts: 21 Location: Chappell Hill, Tx
|
Stream select 9 bit mode dspic33ev256gm004 |
Posted: Tue Nov 05, 2019 4:44 pm |
|
|
I am working on a data collection system where I poll multiple slave data acquisition boards using the 9 bit addressing mode. I have worked through the slave side of things and have code that I think is close to try but on the master I ran into a problem.
In the 9 bit mode the dspic I am working with (dspic33ev256gm004) expects a word transmit/receive for the 9 bit communication where the low bit of the high byte is a 1 for address interrupts, and is a 0 for data. To accommodate that the CCS getc() and the putc() functions work with words instead of bytes in the 9 bit mode (long_word).
I can see how that works, but when I got to the master which reads the 9 bit data from one #use 232 defined port (stream is named slave for discussion) and wants to write to another 8 bit port (stream named telem)
I can't figure out how to switch between the two streams. Well I can define the stream for the 8 bit one (telem) with fputc(telem) but I don't know how to address the 9 bit stream.
Is there a corresponding fgetc() and fputc() for the 9 bit mode which works with words so I can define the stream? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19509
|
|
Posted: Wed Nov 06, 2019 12:06 am |
|
|
If you have 'LONG_DATA' in the #USE setting up the streams, both fgetc
and fputc then accept/retrieve words. Even more surprising;ly and
impressively fprintf, will also send a word for %c, and the internal
buffering also handles words. |
|
|
chaphill
Joined: 07 May 2019 Posts: 21 Location: Chappell Hill, Tx
|
|
Posted: Wed Nov 06, 2019 8:54 am |
|
|
Fantastic! I hope to have enough hardware put together to begin smoke testing real soon. Thanks! |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19509
|
|
Posted: Wed Nov 06, 2019 9:05 am |
|
|
Funnily I'm just doing a job using 9bit, and had queried CCS as to whether
the 'built in' buffering would handle this.
Seems slightly 'odd' to be using the low bit as the flag. Normally using
the high bit is easier, since you can just test this and then omit it. |
|
|
|