PIC SPI Connection.

Discussion in 'Programmer's Corner' started by R!f@@, Sep 12, 2016.

  1. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,733
    759
    PIC.png
    Above is pin out of the pic in question.
    1. The SPI connection are RC3, RC4, and RC5 ? Right ?
    2. I have read the RA5 (SS) - slave select pin can be any digital IO ? Is it true ?
    3. If I were to use 3 SPI slaves, I have to use additional 3 digital IO's (say..RC0,RC1 & RC2) as chip select pins. Right ?
    4. The Pins in Q1 above is same for all 3 SPI slaves. while the chip selects are unique to each Slave..Right ?
    5. RC7 & RC6 re not used in SPI but for serial data like serial port in a computer. Right ?
     
  2. AlbertHall

    Well-Known Member

    Jun 4, 2014
    1,873
    369
    Yes. Your three chip select pins are three slave select pins (SS) and can be any output pin you like.
     
    R!f@@ likes this.
  3. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,733
    759
    So all the questions are spot on ?
     
  4. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,300
    879
    Right.
    Right, provided you've configured the SPI for master operation; if you've configured it so that the PIC is an SPI slave, the SS- pin functions as the chip select input.
    Right.
    Right.
    Right.
     
  5. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,733
    759
    Aaah ! I was wondering about SS pin.
    It must be used if PIC is in slave mode. That explains a lot.
    As I said before, I am planning to buy those SPI ADC's, So PIC will be the Master.
    Thanks all.

    One more q ?
    joeyd999 said I could use the TX pin to drive the buzzer. So I am going to experiment on it.
    Question is if I use TX (RC6) pin to drive the buzzer with the baud rate I select, can I use the RX (RC7) as a normal digital IO.
    Or will the RX pin be configured along with TX pin and cannot be used for any other purpose ?
     
  6. AlbertHall

    Well-Known Member

    Jun 4, 2014
    1,873
    369
    No you can't - from the datasheet:
    upload_2016-9-12_12-43-27.png
     
  7. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,300
    879
    Yes, you can do that. In most of my PIC projects I've used the UART as a diagnostic interface, with TXD and RXD connected to a header for an FTDI cable. Very handy for reporting status, computation results, etc. during execution. In some projects, I've also used it to control operations during factory calibration & test.
    It can still be used as a digital input, but not as an output.
     
  8. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,733
    759
    In short, if TX pin can be used as TX, the RX pin will be a Digital Input ONLY.
    Can it be used as a Switch input for other purposes ? Not like RX data ?
     
  9. AlbertHall

    Well-Known Member

    Jun 4, 2014
    1,873
    369
    Yes, digital input is OK.
     
    R!f@@ likes this.
  10. R!f@@

    Thread Starter AAC Fanatic!

    Apr 2, 2009
    8,733
    759
    Got it.
    Thanks to both of you.
     
  11. OBW0549

    Well-Known Member

    Mar 2, 2015
    1,300
    879
    Sure. It can serve as a digital input for whatever purpose you want. Of course, anything happening on that pin will eventually drive the UART receiver section batsh*t crazy with tons of framing errors, FIFO overruns, and whatever, but AFAIK this doesn't affect the transmitter half of the UART in any way. DO consult the data sheet to make sure, though.
     
    R!f@@ likes this.
Loading...