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
Posted: Wed Nov 18, 2026 5:31 am
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.
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