PDA

View Full Version : SPI Using PIC18F4550 Question



rsocor01
- 27th June 2015, 04:27
Hi all,

I'm trying to use the SHIFTOUT and SHIFTIN commands on a 18F4550 to control and NFC module. The port labels on the 18F4550 refer as SCK, SDI, and SDO. However, the SPI ports on the NFC module are named MOSI, MISO, SCK, SSEL.

The SSEL can be any of the PIC I/O digital pins. All it's needed is a change of state to LOW to enable the SPI communication. Now, are we talking about two different types of SPIs here since the names are different. How do the SDI and SDO relate to the MISO and the MOSI?

Any help will be greatly appreciated. Thank you,

Robert

richard
- 27th June 2015, 04:50
How do the SDI and SDO relate to the MISO and the MOSI?

THE mssp module of the pic can be either spi or i2c so the pin names aren't exactly the same
miso is sdo would connect to mosi on your device
misi is sdi would connect to miso on your device
sck is sck would connect to sck on your device

pbp has no spi hardware module commands at all , shiftin /out they can bit bang on any pins

in you examples folder there are demo spi slave/master programs

rsocor01
- 27th June 2015, 12:32
miso is sdo would connect to mosi on your device
misi is sdi would connect to miso on your device


Hmm, I'm not sure about that. I know that SDI (Master) goes connected to SDO (Slave) and SDO (Master) goes to SDI (Slave). But, a quick search in Google for SPI wiring will bring you some circuits like this,

7879

As you can see MOSI goes to MOSI and MISO goes to MISO. :confused: :confused: :confused: . I am trying to connect my PIC to an NFC module that only accepts SPI. The ports of the module are labeled as MOSI, MISO, SCK, and SSEL. I haven't had any luck getting a response from the module yet. Can I use SHIFTIN and SHIFTOUT in this case?

richard
- 27th June 2015, 14:33
you will need to refer to the docs of your nfc module to verify what is an input and what is an output to be sure. as a general rule inputs connect to outputs , connecting outputs together is bad and connecting inputs together is going to go nowhere
see this extract for a rfm69w module the pins function and role is explicitly defined

richard
- 27th June 2015, 14:37
Can I use SHIFTIN and SHIFTOUT in this case?

shiftin/out will work just fine once you know what's an input and what's an output

rsocor01
- 28th June 2015, 12:30
Richard, I've finally got it to work. Thanks for your help. My next step would be to use the hardware MSSP as SPI after I have all my commands working right.