Questions about SPI ...

Discussion in 'Embedded Systems and Microcontrollers' started by AKdaBAOUS, Nov 18, 2013.

  1. AKdaBAOUS

    Thread Starter New Member

    Nov 18, 2013
    2
    0
    Dear Forum Members,

    As you can see, I'm new to the forum so I apologise in advance if I have posted in the wrong section.

    I just wanted to have a few things clarified about SPI - but first, a bit of backstory/project info ...

    I'm a University student and I've taken a turn from my Robotics hobby to work more on strengthening my Electronics/Programming skills so I decided to start work on a project that I had in mind which involves (for starters) interfacing a TFT LCD display with a basic ARM Cortex-M3 processor (the LPC1343 from NXP to be more specific). Communication would be via SPI. I've had some experience playing around with displays from Adafruit with my Arduino Uno but that's about the extent of it. :/

    So onto my question - I've been reading a lot about pull-up/pull-down resistors on the data lines with some people saying they need them and some saying they don't bother with them. I believe the general consensus is that they're required on the Slave Select pins but as for the rest, I'm clueless. :(
    I'd assume for a single device, it wouldn't matter that much however I would at some point like to 'hook up' other devices (uSD card, etc.) and I'm guessing this would change the situation?

    Would someone mind giving me a quick breakdown on this whole scenario or would it just be easier for me to add the resistors on the board but only populate them if required? :confused:

    I've attached the datasheets for both the processor and display if they can help in any way.

    Thanks in advance! :)

    Regards,
    AKdaBAOUS
     
  2. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    SPI (Serial Peripheral Interface) consists of four signals plus GND.

    MOSI - Master Out Slave In
    MISO - Master In Slave Out
    SCLK - Serial Clock
    SS - Slave Select (active LOW)

    In a system configuration there is always a designated master and any number of slaves.
    Since all the signal lines are driven (MOSI, SCLK and SS are driven by the master) there is no need for pull-up resistors.

    However, if no slave is encountered or the slave is slow at responding a weak pull-up (10k - 100kΩ) on the MISO line would not hurt, though not essential.
     
    AKdaBAOUS likes this.
  3. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    The only addition I can make to what MrChips said might be to use pull up resistors(~10k) on the Slave Select(SS) lines since you intend to use multiple SPI slaves to a single master. This way, should the master fail, assuming the outputs fail open, the SPI slaves would default to a non-selected state.

    This, however, is not essential to operation, but more of a failsafe precaution.
     
    AKdaBAOUS likes this.
  4. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    Note that for multiple slaves, the slaves would not be selected by a single SS output from the master. Each slave will have a unique SS output from the master.
     
  5. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
    I'd been lead to believe that a pull-up on SS was a good idea because at restart the status of the MCU pins could be floating and so a slave may be selected unintentionally.

    [edit]
    Cross-posted with tshuck but same thing with slightly different reasons
    [/edit]
     
    AKdaBAOUS likes this.
  6. AKdaBAOUS

    Thread Starter New Member

    Nov 18, 2013
    2
    0
    Thanks for all the replies guys - they've been very helpful. :D
    Once this project gets properly underway, I'll be uploading it for anyone who might find parts of it helpful in any way. ^___^

    Thanks again! ;)

    Regards,
    AKdaBAOUS
     
  7. tshuck

    Well-Known Member

    Oct 18, 2012
    3,531
    675
    That is a good point, much more compelling than mine...:D
     
  8. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    All valid points. But note that if the MCU is not functioning there will be no SCLK and no valid MOSI signal.
     
  9. t06afre

    AAC Fanatic!

    May 11, 2009
    5,939
    1,222
    AKdaBAOUS likes this.
  10. sirch2

    Well-Known Member

    Jan 21, 2013
    1,008
    351
    Yes, it really is being pretty cautious but if you have something like an SD card holding data and it gets selected, there is the remote possibility that noise on the data/clock lines could just happen to delete/corrupt the data. Extremely unlikely but sod's law and all that.
     
  11. MrChips

    Moderator

    Oct 2, 2009
    12,414
    3,353
    Yes, I was going to add that it depends on what the device does.
    If it is an ADC then it doesn't matter. An SD card or EEPROM is a different story.

    As a systems designer I too have to worry about Murphy's Laws.

    Yes, put a pull-up resistor on SS if it is a critical component.
     
    AKdaBAOUS likes this.
Loading...