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

Stream select 9 bit mode dspic33ev256gm004

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



Joined: 07 May 2019
Posts: 21
Location: Chappell Hill, Tx

View user's profile Send private message

Stream select 9 bit mode dspic33ev256gm004
PostPosted: Tue Nov 05, 2019 4:44 pm     Reply with quote

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: 19195

View user's profile Send private message

PostPosted: Wed Nov 06, 2019 12:06 am     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 06, 2019 8:54 am     Reply with quote

Fantastic! I hope to have enough hardware put together to begin smoke testing real soon. Thanks!
Ttelmah



Joined: 11 Mar 2010
Posts: 19195

View user's profile Send private message

PostPosted: Wed Nov 06, 2019 9:05 am     Reply with quote

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.
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