Shop OBEX P1 Docs P2 Docs Learn Events
Can't get the FAT32 object to create a new file — Parallax Forums

Can't get the FAT32 object to create a new file

Hello all,

I can't create a file on a SD card, I'm using the Parallax terminal to validate the output, but it just dies when it is new file time. I am using prop tool ver. 2.9.3 and the P2 edge. I have attached ( what I thought was) simple test code. What mistake am I making?

Thanks,
Rob.

Comments

  • You're calling FATEngineStart with the fifth parameter set to the write-protect pin (-1), when that parameter actually affects the readOnly setting. Set to anything other than 0 and you can't write to the card.
    Give this a try, it worked for me:

      fat.FATEngineStart(_SD_DO, _SD_CLK, _SD_DI, _SD_CS, 0)
      fat.mountPartition(0)
      fat.newFile(string("test.txt"))
      fat.closeFile()
      fat.openFile(string("test.txt"),"w")
      fat.writeString(string("this is file test.txt"))
      fat.closeFile()
    
      fat.openFile(string("test.txt"),"r")
      fat.readData(@buffer,fat.fileSize())
      debug(zstr(@buffer))
    
  • That worked, Thanks!

Sign In or Register to comment.