Trouble sharing SPI pins with SD Card and another device using fsrw26

dbpagedbpage Posts: 179
edited 2018-05-14 - 18:08:43 in Propeller 1
I have been using fsrw26 for many years without issue. I often use multiple instance of fsrw26 to work with multiple files without issue.

I am currently working with a hardware design that shares SPI pins with another device. My goal is to read data from an SD card and, using the same SPI pins, to transmit the data to another device. The SD card and other device share CLK, MISO, MOSI pins, and each have their own dedicated CS pins. The pins have pull up resistors.

It appears to me that when fsrw26 mounts the SD card, opens a file and reads a byte, fsrw26 does not release the SD Card CS pin; the pin remains actively driven low.

There are PASM lines in safe_SPI that read:
        ' if you are using pull-up resistors, and need all
        ' lines tristated, then uncomment the following line.
        ' for Cluso99
'       mov dira,#0

Uncommenting this line does not resolve the issue.

Is there a magic bullet that you can share to accomplish my goal?

Edit: Uploaded a schematic diagram


  • There are no pullups on the CS lines in that diagram.
  • Peter JakackiPeter Jakacki Posts: 8,157
    edited 2018-05-15 - 12:02:49
    Pullups aren't needed on SD CS lines as a pullup is active on the SD card itself which is used for detecting whether the card is inserted. Of course if it isn't inserted, why do you need a pullup especially since the CS is an output from the Prop. I don't use any pullups at all in my commercial designs.

    If you are using multiple instances of fsrw then that means they are running in multiple cogs which means that if any cog leaves an output high then another cog will not be able to take it low since outputs are OR'd.

    However in this case it may simply be that the SD card itself still has data out active even though the CS line has been deactivated. I normally run a few more clocks after access before de-asserting CS. The other thing that can happen is that I've seen certain non-Sandisk cards output clock pulses onto the DI line at power-up, totally non-standard.Try using a genuine (non-ebay) Sandisk card.

    BTW, my Tachyon file-system normally supports up to four open files and the only reason I don't normally support more is because I have better uses for all that memory.

    Tachyon Forth - compact, fast, forthwright and interactive
    --->CLICK THE LOGO for more links<---
    P1 +++++ Latest binary V5.4 includes EASYFILE +++++ Tachyon Forth News Blog
    Brisbane, Australia
  • Good point. The mov dira,#0 instruction is supposed to tristates all pins, including CS and CLK. The pull up resistors are there but I uploaded the wrong schematic diagram. Attached is the correct diagram.

    I don't rely on the SD Card having pullup resistors. I use cards branded by Parallax or MicroCenter. The customer may substitute brand X. I recall fsrw26 running a few extra clocks. I'll look to see when.

    I conducted additional tests. The SD Card CS pin remains actively driven low after mounting the SD Card. The SD Card CS pin floats after unmounting the SD card. This is true if I comment or uncomment mov dira,#0.
Sign In or Register to comment.