Starting From Scratch learning the Fat Engine. A few questions.
T Chap
Posts: 4,223
I have been going through the app notes on the Fat engine(S35390A_SD-MMC_FATEngine) all weekend and have just now made some progress being able to write and read data to the drive so that it is starting to make sense. There are few questions that I can't solve. I will also use this thread to post a schematic for a board design using the RTC and SD card(same idea as the Spinneret components). The new board will be dedicated to the RTC, SD card, SD wav playback with Line Outs + speaker outs to free up the main Prop board.
In the PST display below, no matter what gets written to the card, the Free and Used never changes. Does anyone see what would cause this to display values that are the same every time I append? In the app notes:
Below is the scratchpad of test code:
In the PST display below, no matter what gets written to the card, the Free and Used never changes. Does anyone see what would cause this to display values that are the same every time I append? In the app notes:
. I don't think a byte will take up an entire cluster, so maybe this is the confusion.The default allocation unit for the FAT16/32 file system is the cluster, and files or folders span one or more clusters. This means a one-byte file takes up an entire cluster.
17309 Mo: 12 Dt: 29 Day: 7 Hr: 19 Min: 27 mountPartition: 0 Mounted(T/F) -1 Open For Write: TEXT2.TXT ReadByte 01234567893123123123123123 List entries: TEXT.TXT List entries: TEXT2.TXT List entries: List entries: TEXT.TXT List entries: TEXT2.TXT List entries: CloseFile: 0 Free: 7721192 Used: 8 UNmountPartition: 0
Below is the scratchpad of test code:
PUB Init | aa, counter, buffer[128] pst.Start(115200) pst.Clear pst.str(string("Start PST")) pst.LineFeed pst.LineFeed pst.LineFeed 'pst.dec(sd.FATEngineStart(_cardDataOutPin, _cardClockPin, _cardDataInPin, _cardChipSelectPin, -1, -1, { ' } I2C_DATA, I2C_CLOCK, -1)) 'wrap long line to here 'this returns a -1 for true = success StartFatWithLEDStatus dira[_statuspin]~~ repeat 5 outa[_statuspin]~~ waitcnt(5_000_000 + cnt) outa[_statuspin]~ waitcnt(5_000_000 + cnt) waitcnt(1000000 + cnt) pst.dec(sd.readTime) ' returns combined time Initite the read before gettin the time waitcnt(1000000 + cnt) pst.LineFeed pst.str(string("Mo: ")) pst.dec(sd.getmonth) waitcnt(1000000 + cnt) pst.LineFeed pst.str(string("Dt: ")) pst.dec(sd.getDate) waitcnt(1000000 + cnt) pst.LineFeed pst.str(string("Day: ")) pst.dec(sd.getDay) waitcnt(1000000 + cnt) pst.LineFeed pst.str(string("Hr: ")) pst.dec(sd.getHour) waitcnt(1000000 + cnt) pst.LineFeed pst.str(string("Min: ")) pst.dec(sd.getMinute) waitcnt(1000000 + cnt) pst.LineFeed 'pst.dec(sd.formatPartition(0)) 'pst.LineFeed 'repeat 'pst.str(string("UNmountPartition: ")) 'pst.dec(sd.unmountPartition) 'pst.LineFeed pst.str(string("mountPartition: ")) '0 - false -1 = true pst.dec(sd.mountPartition(0)) pst.LineFeed pst.str(string("Mounted(T/F) ")) pst.dec(sd.partitionMounted) '0 - false -1 = true pst.LineFeed 'partitionCardNotDetected 'pst.str(string("CloseFile: ")) 'pst.dec(sd.closefile) 'pst.LineFeed 'pst.str(string("Open For Write: ")) 'pst.str(sd.openFile(string("text.txt"), "W")) ' Open text.txt for appending. 'pst.LineFeed pst.str(string("Open For Write: ")) pst.str(sd.openFile(string("text2.txt"), "W")) ' Open text.txt for appending. pst.LineFeed 'pst.str((sd.openFile(sd.newFile(string("text2.txt")), "W"))) '00000000 'pst.LineFeed 'pst.str(string("UNmountPartition: ")) 'pst.dec(sd.unmountPartition) 'pst.LineFeed 'pst.str(string("Open For Write: ")) 'pst.str(sd.openFile(string("text.txt"), "W")) ' Open text.txt for appending. sd.writeString(string("0123456789")) pst.LineFeed 'pst.str(string("openFile: ")) 'pst.str(sd.openFile(string("text.txt"), "R")) ' Open text.txt. '00000000 'pst.LineFeed 'sd.writeString(string("0123456789")) 'pst.LineFeed 'pst.str(string("Readstring ")) sd.fileSeek(0) 'sd.Readstring(@buffer, 512) pst.str(string("ReadByte ")) sd.Readstring(@buffer, 512) 'pst.dec(sd.ReadByte) pst.str(@buffer) pst.LineFeed 'pst.str(string("writeString: ")) 'pst.dec(sd.writeString(string("Appended Data") ) ) '00000000 'pst.LineFeed 'pst.str(string("FlushData: ")) 'pst.dec(sd.flushData) 'pst.LineFeed repeat 6 pst.str(string("List entries: ")) pst.str(sd.listentries("/")) pst.LineFeed pst.str(string("CloseFile: ")) pst.dec(sd.closefile) pst.LineFeed ''pst.str(sd.readString("text.txt")) '?? pst.LineFeed pst.str(string("Free: ")) pst.dec(sd.partitionFreeSectorCount("F")) pst.LineFeed pst.str(string("Used: ")) pst.dec(sd.partitionUsedSectorCount("F")) pst.LineFeed pst.str(string("UNmountPartition: ")) pst.dec(sd.unmountPartition) pst.LineFeed repeat
Comments