SPI - SDI pin really available?

Discussion in 'Embedded Systems and Microcontrollers' started by atferrari, Jan 31, 2014.

  1. atferrari

    Thread Starter AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    DOUBT SOLVED: see my last post below

    PIC 18F family - Assembler.

    I implemented the addressing / data buses to write / read an EEPROM using a string of 74HC595 shift registers. It worked OK.

    When implemented a more "adult" version with just IO pins from a 18F4520, started to get massive (but consistent) errors.

    Since I peek at the data through a 74HC595 shift register driven by the SPI module (Master mode), I need to discard this doubt:

    Is the SDI pin really available to me? If so, just as an output, right?

    After burning my last 18F4520 (yes, I still do things like that) I am going back to the 18F452 (have plenty around).

    Please read the excerpt from its datasheet (same wording as for the the late 18F4520).

    Just in case, while I know that the /SS TRIS position is WRONG, that pin is not relevant here because the SPI is Master.

    Any comment appreciated.
     
    Last edited: Feb 8, 2014
  2. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    SDI is the input pin for SPI. You would need to set your TRIS bit for that pin as input. You should also be sure to set it as a binary input if can also be an analog input pin.


    You should also have a SDO pin you would need to set the TRIS for that pin to output,

    These pins are not interchangeable unless (if memory serves) they are also programmable function pins.
     
  3. JohnInTX

    Moderator

    Jun 26, 2012
    2,347
    1,029
    Well I confess I never really considered that last part you circled. Like spinnaker, I just do SPI or not. BUT, the datasheet says it should work.. maybe.

    First, do you have the latest datasheet? Mine is Rev E but that may not be the latest. I say that because the section you refer is in chapter 17 in mine, not 15. So be sure you have the latest one.

    Second, get ALL of the errata for your particular silicon version. The errata for A1 silicon has this little gem:

    That doesn't address your SDI question but says that there have been some similar problems in the area. (It looks like it was cleared up in the Rev Bx silicon). And unfortunately, there have been LOTS of issues with the MSSP for lots of parts... Remember: The datasheet giveth - the errata taketh away. And as one who over the years has identified a couple of issues that have been later enshrined in errata, my advice is to move the pin.

    BTW, your programmer should report the silicon version.
    EDIT: If after all of this, you think it should work open a support ticket at microchip.com. Not all known problems get to the errata before you encounter them. If you are misunderstanding something, they will work to clear it up. They really do try to fix problems.

    Good luck!
     
    Last edited: Jan 31, 2014
  4. ErnieM

    AAC Fanatic!

    Apr 24, 2011
    7,392
    1,605
    Quote of the day !!!
     
    atferrari likes this.
  5. atferrari

    Thread Starter AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Besides possible errata, I understand that I should be able to use it as an output. Anyway, for the moment I keep the SDI pin, NC.

    Thanks for the replies.
     
  6. THE_RB

    AAC Fanatic!

    Feb 11, 2008
    5,435
    1,305
    Does the datasheet section on ports show the logic gate diagram for that port pin? The better datasheets always used to show that.

    If it does, that will show you if TRISx over-rides the other functions and can force the pin to be an output.
     
  7. atferrari

    Thread Starter AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Not specific for THAT one. It is generic for any pin.

    After thinking of it I presume that I should be able to have it available as OUT pin, otherwise it is automatically IN (and acting as SDI for the peripheric, SPI in this case).

    Still wondering why peripherics' pins are "scattered" all over and there isn't at least one single port which is pure IN/OUT.

    Thanks to you all for replying.
     
  8. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012

    I don't understand your complaint. Are you complaining that pins do more than binary i/o? I for one am glad of that.
     
  9. atferrari

    Thread Starter AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    I say that I would like to see at least one of the ports uncomitted to peripherics, just plain IO to avoid changing port selection when a peripheric enter/leaves the game during design.

    Yes, higher families have configurable ones. Would like to have that, all neatly ranged where I need them...!
     
  10. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    4,887
    1,012
    I would like to see port pins lined up. Often they are not but I understand why that might be difficult especially when dealing with various types of packaging.
     
  11. atferrari

    Thread Starter AAC Fanatic!

    Jan 6, 2004
    2,648
    764
    Now that my design seems to be bug-free, :rolleyes: I made a proper test with SPI in action.

    Doubt solved.

    As the datasheet allows to presume, if I make TRISC,4 =0, when SSPCON1,SSPEN =1, the pin IS available as an output.

    Thanks to you all for replying.
     
    Last edited: Feb 8, 2014
    JohnInTX likes this.
  12. Gorgon

    Senior Member

    Aug 14, 2005
    113
    0
    Even if the SDI pin is working as an output, it could still be that the value of the pin is used in the SPI engine. Since you don't use the input, it is of no actual interest. From the text in the datasheet, it looks like the 'input' from the SDI pin is fixed in the SPI engine.
     
Loading...