1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

PIC 16F628 ( or others) as a SPI slave

Discussion in 'Oshonsoft' started by jpdn, Dec 5, 2014.

  1. jpdn

    jpdn New Member

    Joined:
    Apr 4, 2012
    Messages:
    2
    Likes:
    0
    I am trying to connect a Raspberry Pi to a Pic using SPI interface.
    In my case I want the Raspberry to be the Master and the Pic to be the slave.
    The Raspberry send a request for data (temperature) to the Pic, and the Pic replies with a value.
    SPI is needed in order to communicate via a pair of 2.1Ghz RF transceivers NRF24L01

    However the commands for SPI included in OnshonSoft seem to be only for making the PIC acting as a Master and not as a Slave :+((

    Is this correct ?
    Is there a way to go around ?
    Thanks in advance
    JP
     
  2. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE
    Of course there is.... You can set up slave SPI using the registers directly... However!! if they are both communicating with RF transceivers...... Why???... The SPI master is both ends, the slaves are the RF transceivers..
     
  3. jpdn

    jpdn New Member

    Joined:
    Apr 4, 2012
    Messages:
    2
    Likes:
    0
    Thank you for the fast reply.

    I think that I understand what you mean: For the PIC, the , you mean that the NRF24L01 device is considered as a slave device , and the Pic is the master . Right ?

    But so if the Raspberry send a request for data (i.e temperature), how can the Pic be only waiting for a request to come from the Raspberry?

    I have started my project with UART and 433Mhz transmitter, but the 433Mhz signal is too noisy ( when the Raspberry is now transmitting, the receiver pick up noise which makes the UART mad.)

    So I decided to move to NRF24L01 which take care of the noise filtering in transmission but use a SPI interface.

    May be I misunderstood the concept of the NRF24L01, as I thought it will allows me to transfer data in both direction as UART/RS232.

    JP

    The NRF24L01 is both a transmitter and a receiver on a single small board ,with only these pins + power supply.
    =====================================================

    IRQ


    (this signal is active low and is controlled by three maskable interrupt sources)


    CE (this signal is active high and is used to activate the chip in RX or TX mode)


    CSN (SPI signal)


    SCK (SPI signal)


    MOSI (SPI signal)


    MISO (SPI signal)

    =============================================================
     
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. Ian Rogers

    Ian Rogers Super Moderator Most Helpful Member

    Joined:
    Mar 28, 2011
    Messages:
    9,310
    Likes:
    914
    Location:
    Rochdale UK
    ONLINE

    I would need to devour the RF datasheet, but I would imagine your Pi would ask for data.... The RF would transmit and use the IRQ line to prompt the Pic for the data... If I get some time today, I shall indeed scan through said datasheet..

    These RF modules are used quite a bit so there must be examples on the net.....
     

Share This Page