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 CCS Technical Support

5.125 / #use spi

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



Joined: 24 Jun 2004
Posts: 1945

View user's profile Send private message

5.125 / #use spi
PostPosted: Tue Nov 17, 2026 7:41 am     Reply with quote

18F56Q43 - SPI peripherals. I'm curious if anyone knows the proper keyword to use in the #use spi directive to tell the compiler that you just want a TX only implementation or a RX only implementation.

As it is the compiler will properly set up the peripheral but it always enables both TX and RX. I cannot find in the help file any mention of a keyword(s) that would encourage the compiler to use one or the other.

I can easily enough get my way round this by setting the appropriate registers myself but was curious if there's some sort of magic handshake I'm not privy to?
Ttelmah



Joined: 11 Mar 2010
Posts: 20156

View user's profile Send private message

PostPosted: Wed Nov 18, 2026 5:31 am     Reply with quote

SPI is normally always a bi-directional interface.
How you do this depends a little on what your chip allows with PPS.

On some chips:
All you do is set the SPI up with with PPS and both SDO and SDI
implemented. Use a pin that will not matter at the moment of boot for
the SDI pin. Then at the start of your code use an inline PPS command to
say the SDI is connected to NULL In fact you can simply leave the SDI
connected to another pin that you use as an input. It'll just read this pin
and get garbage. This is usually the easiest route.
On other chips they will accept a pin as both input and output for PPS, and
all you do is setup the PPS sop the same pin is used for both SDO and SDI.
That way the SDI will read what is sent.

I'd suspect being a PIC18, you will need to use the former approach. It
is normal only the PIC24's and on that support using the single pin as
both input and output.
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