Shop OBEX P1 Docs P2 Docs Learn Events
Mysterious fsrw26 SD Card unmount — Parallax Forums

Mysterious fsrw26 SD Card unmount

My SD Card unmounts itself mysteriously using fsrw26.

I have a method that parses an ASCII file, reading one line at a time, until the end of file. I have a second method that reopens the same file and parses the ASCII file in another way. I am not certain that the SD Card is unmounted. I only know that I have to mount the SD Card again before the second method can open and read the ASCII file.

Is there something about fsrw26 that requires the second method to re-mount the SD Card if no files are open after a short period of time?

Between the first and second parsing methods, the SPI bus is used to send information to another device on the same SPI bus. The SD Card and other device share the DO CLK DI pins. Each has its own CS pin. I am using pull up resistors and have uncommented the command mov dira,#0 in safe_spi PASM to tristate all lines so that the SPI bus can be shared with other devices.

Could there be something about sharing the SPI bus that causes the SD Card to need re-mounting between file accesses?

Comments

  • I see that fsrw auto-releases the SPI bus after the idle_limit is reached. Idle_limit is initialized to 125ms. "Release" may also be called. I don't know how to resume fsrw after release so that the code can read the next ASCII record.

    I want to keep a file open and alternate between reading an ASCII record and writing to an external SPI device like this:
      SPI.start(15,1)                                       
      \sd.mount(4)
      \sd.popen(@HexFile,"r")
      repeat
        <read ASCII record>
        <write to external SPI device>
      until <end of file>
      sd.pclose
    

    I am looking at this very old post from 2009, when lonesock was working on fsrw 2.5
    https://forums.parallax.com/discussion/117409/sharing-sd-spi-pins-without-unmounting

    Lonesock wrote that "FSRW will automatically reacquire the lines next time you ask 'sdfat' to do something." The only command that fsrw responds to is sd.mount, after which I have to re-open the file.

    Is there a way that I get fsrw to reacquire the SPI lines without re-mounting and re-opening the file so that the code can read the next ASCII record?
  • dbpage wrote: »
    I see that fsrw auto-releases the SPI bus after the idle_limit is reached. Idle_limit is initialized to 125ms. "Release" may also be called. I don't know how to resume fsrw after release so that the code can read the next ASCII record.

    I want to keep a file open and alternate between reading an ASCII record and writing to an external SPI device like this:
      SPI.start(15,1)                                       
      \sd.mount(4)
      \sd.popen(@HexFile,"r")
      repeat
        <read ASCII record>
        <write to external SPI device>
      until <end of file>
      sd.pclose
    

    I am looking at this very old post from 2009, when lonesock was working on fsrw 2.5
    https://forums.parallax.com/discussion/117409/sharing-sd-spi-pins-without-unmounting

    Lonesock wrote that "FSRW will automatically reacquire the lines next time you ask 'sdfat' to do something." The only command that fsrw responds to is sd.mount, after which I have to re-open the file.

    Is there a way that I get fsrw to reacquire the SPI lines without re-mounting and re-opening the file so that the code can read the next ASCII record?

    As long as you are not sharing pins for the spi device you can just comment out the section that unmounts the card after 30 seconds of inactivity. I don't recommend sharing the SD card pins with other SPI devices unless you unmount the card every time you access the other SPI device as I've had problems. Sometimes it works but I've had problems with this in the past.
  • My system is sharing 3 SPI pins. The SPI pins are released by fsrw due to its 125ms auto-release.

    Is there a way for fsrw to regain control of the SPI pins without losing its place in the open ASCII file?
Sign In or Register to comment.