Announcement

Collapse
No announcement yet.

SPI1 state of SDO after write

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • SPI1 state of SDO after write

    What is the state of SDO after a write? Does it go HiZ or stay high/low depending on the mode? I need to communicate with a device that has a common SDO and SDI line (SDIO) but no CS line. The controller always initiates response from the device. The mode is that the controller sends an 8 bit word, sets SDIO to HiZ following the last bit, the device responds on the next clock raise with an 8 bit response.

  • #2
    Hello Alexander,

    The SDI and SDO are push pull and the states are either Hi or Lo.

    You'll need to choose one pin that could be used as both SDI and SDO.

    Every time you need to read, you'll need to set the pin as an input(SDI) and set it as output(SDO) for every write

    I hope this helps.

    Best regards,
    Michael

    Comment


    • #3
      Will the SPI need to be re-intialized after each pin change?

      Comment


      • #4
        In the Diablo 16 Internal Functions document / page 235 / SPI1_Read() or SPI2_Read() or SPI3_Read() / In "Description" it says "A dummy write using all bits set is automatically written to the SPI port to being the read." Does this mean it writes a 0b11111111 to SDO?

        Comment


        • #5
          Hello Alexander,

          It means that you don't need to use a SPIx_Write(); command before every SPIx_Read();
          SPIx_Read(); "Automatically" initiates an SPIx_Write();.

          You can check the other device if a dummy write is needed before doing a read.

          You could refer to this forum thread for more information:

          SPI communication
          https://forum.4dsystems.com.au/node/41277

          Best regards,

          Michael

          Comment


          • #6
            After reading that thread it appears I will have to bit bang it instead of the SPI provided unless you see a way to get the shared SDIO line to a high Z state after a write and do a read on the next clock rise. I do have level translators with direction and state select-able on the fly.

            Click image for larger version

Name:	SPI Read Timing.JPG
Views:	1
Size:	460.9 KB
ID:	66298

            Comment


            • #7
              a tri state buffer is what you would need for hardware spi if the SDO line doesnt play nice

              Tony

              Comment


              • #8
                Yes, but timing is the problem with the built in SPI. How to change the pin state for the EN pin at the falling edge of the clock after the last SDO bit? I can achieve that with bit bang since I control both the clock and SDO bits, but don't see a way with the built in SPI without rewriting it. Perhaps I'm just overlooking a way as I tend not to see some of the simpler things sometimes.
                Last edited by Alexander Mundy; 11th December 2018, 10:34 PM.

                Comment


                • #9
                  Hello Alexander,

                  I don't have an SDIO device with me, but I think this should work just fine with the SPIx_Read(); and SPIx_Write(); function.

                  Have you had any issues using those?

                  Best regards,
                  Michael

                  Comment


                  • #10
                    I'm a hobbiest and pretty much working blind with an old single trace scope I've had since the '70's. My wife has allowed me to order a 4 trace scope with serial decode etc for Christmas. Will pick this little project back up after it arrives.

                    Comment

                    Working...
                    X