Shop OBEX P1 Docs P2 Docs Learn Events
New AppNote Posted: FAT16/FAT32 Full File System Driver — Parallax Forums

New AppNote Posted: FAT16/FAT32 Full File System Driver

Ken GraceyKen Gracey Posts: 7,401
edited 2011-06-19 20:12 in Propeller 1
FAT16/32 Full File System Driver

Abstract - Secure Digital (SD) cards have become the choice medium for mass storage in embedded systems. The goal of this application note is to provide the reader with knowledge on how to use SD cards, important features of the FAT file system, and how to use the FAT16/32 Full File System Driver software library for the multicore Propeller P8X32A microcontroller.

AppNote and code are now available at http://www.parallaxsemiconductor.com/an006

You will notice that the contribution is from Kye (Kwabena), a new member of Parallax Semiconductor starting the end of May.

Ken Gracey
«1

Comments

  • RossHRossH Posts: 5,519
    edited 2011-05-10 22:23
    And congratulations to Kye for his FATEngine!
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2011-05-10 23:44
    That's a nicely-done appnote, for sure! Kye has a crisp writing style, which I find very appealing.

    -Phil
  • RossHRossH Posts: 5,519
    edited 2011-05-10 23:47
    I didn't realize Kye had written the appnote as well - also very nicely done.

    Ross.
  • william chanwilliam chan Posts: 1,326
    edited 2011-05-11 00:41
    This is truly an amazing mammoth effort. Congrats!
  • KyeKye Posts: 2,200
    edited 2011-05-11 06:30
    The RTFM emails! Will they stop now? Haha,

    Happy reading people,

    I'll update the obex with the new code too - us the SD/MMC version of the file system driver. Version 3.01 is very similar but sower and larger.
  • wjsteelewjsteele Posts: 697
    edited 2011-05-11 06:37
    Very Nice!!! This is top notch work, Kye!

    Bill
  • Bill HenningBill Henning Posts: 6,445
    edited 2011-05-11 07:00
    Really nice work Kye!

    Very well written app note - and I love the built-in boot from image option.

    A few suggestions:

    - include an approximation of hub memory used
    - document number of cogs uses (I assume only one helper cog)
    - it would be nice for secondary instances to inherit the full state so no need to re-mount etc
    - in the introduction specify that 4-bit mode is not used due to licensing issues
    - I have not read the sources yet, however if you are using a lock, make it configurable
    - next revision should have a defined "SPISelect" method for multiplexed SPI solutions (C3, PropCade, more)

    p.s.

    Congrats on the job for Parallax Semiconductor!
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-05-11 07:20
    I can't seem to open the PDF with the appnote. When I click on the link it takes me to the Parallax main page. I'm sure I've been able to view appnotes before -- has something changed? I don't have a Parallax Semiconductor login, but I didn't have one before when I looked at other appnotes. I did try to register at Parallax Semiconductor, but the register link also takes me to the Parallax main page.

    EDIT: I was able to open it by right-clicking instead of left-clicking. It must be a problem with a setting on my browser.
  • Dr_AculaDr_Acula Posts: 5,484
    edited 2011-05-11 07:32
    Kye's code is top quality and his objects all work in a consistent way. I think all of Kye's code could go straight to the "Gold Standard" Obex.
  • ctwardellctwardell Posts: 1,716
    edited 2011-05-11 07:43
    Congrats to both Parallax Semiconductor and Kye.

    It is good to see top notch people getting to work with top notch companies.

    C.W.
  • Ken GraceyKen Gracey Posts: 7,401
    edited 2011-05-11 08:07
    Dave Hein wrote: »
    I can't seem to open the PDF with the appnote. When I click on the link it takes me to the Parallax main page. I'm sure I've been able to view appnotes before -- has something changed? I don't have a Parallax Semiconductor login, but I didn't have one before when I looked at other appnotes. I did try to register at Parallax Semiconductor, but the register link also takes me to the Parallax main page.

    EDIT: I was able to open it by right-clicking instead of left-clicking. It must be a problem with a setting on my browser.

    Hey Dave, this is the second time we've received the same strange comment. Another visitor told us he was also linked back to the Parallax web site from our AppNotes page but we've been unable to duplicate his problem. Could you give us some information about your browners, OS, etc?

    Thanks,

    Ken Gracey
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-11 08:25
    Congratulations on your new job and nice job on the revised File System Driver and App Note.
  • BTXBTX Posts: 674
    edited 2011-05-11 18:27
    Hey well done, excellent work !! so good that I'm posting too :)
  • BTXBTX Posts: 674
    edited 2011-05-12 10:24
    Sorry for my stupid question but...
    In all demos, the RTC is connected to the pins P28 and P29, what happend with the eeprom in the same pins ? does it work without any conflicts ?
  • Daniel HarrisDaniel Harris Posts: 207
    edited 2011-05-12 10:33
    BTX wrote: »
    Sorry for my stupid question but...
    In all demos, the RTC is connected to the pins P28 and P29, what happend with the eeprom in the same pins ? does it work without any conflicts ?

    Hi BTX,

    No worries, no question is stupid :). The RTCs connected to the I2C lines that the Propeller's EEPROM use will not interfere with the EEPROM's operation. This is because the RTCs have a different device address than the EEPROM. In fact, the I2C communication protocol is meant to be used on a bus - meaning that its OK (and expected) for multiple devices to be on the same bus lines, as long as each device has its own unique address and does not contend with another device on the bus.

    Thanks,
    Daniel
  • BTXBTX Posts: 674
    edited 2011-05-12 10:39
    Thank you Daniel !!
    OK, I'll correct my words, now I'm older an stupid :)
  • Dave HeinDave Hein Posts: 6,347
    edited 2011-05-12 13:57
    Ken Gracey wrote: »
    Hey Dave, this is the second time we've received the same strange comment. Another visitor told us he was also linked back to the Parallax web site from our AppNotes page but we've been unable to duplicate his problem. Could you give us some information about your browners, OS, etc?
    The problem happens on my computer at work, which is running Windows XP Professional, Version 2002, SP3. The link works fine with Google Chrome on this computer, but goes to the Parallax main page when I try it in Internet Explorer 7. It is version 7.0.5730.13. I've tried various option settings, but the link doesn't work if I left-click it on the IE7 browser. It does work if I right-click and select one of the display options that way.

    EDIT: The problem seems to be due to a security thing in IE7. It works OK if I disable scripts and Active X controls, but fails if these are enabled.
  • BTXBTX Posts: 674
    edited 2011-05-13 10:05
    Hi guys again me with questions....
    Looking close at this configuration, I can see it is possible to use DS1307 RTC which is interesting to me. But this chip is 5Vcc power, schema at the drivers, about how to connect it, says that we need two 10k resistors to Vdd 3.3V, and wire directly to pchip pins P28 and P29.
    What happend with the 5V out for the DS1307 pins?, no resistors in serie with the pchip ?
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2011-05-13 10:23
    BTX,

    10K seems a bit high to me. I would still use 4.7K, however the reason you don't need series resistors with the DS1307 is that I2C devices only drive the signal line low, not high (open collector). So when the lines are pulled to 3.3V, the signals are only ever 3.3V or ground, making them perfectly compatible with the Propeller chip. I hope this helps.
  • Bob Lawrence (VE1RLL)Bob Lawrence (VE1RLL) Posts: 1,720
    edited 2011-05-13 10:51
    Excellent job Nyamekye . I enjoyed reading and learning from it.

    Bob
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-13 10:56
    Here's one suggestion for a version of this driver for the C3 board. Instead of passing a /CS pin number, you pass the pin number of the clear SPI select counter pin in the most significant word and the pin number of the count SPI select counter pin in the least significant word. The select number for the SD card (5) is fixed in the driver as a constant. The only changes are to FATEngineStart and to the assembly driver in commandSPI and shutdownSPI. Another pin mask, counterClearPin, is added.

    There's no locking done for the SPI bus. This may cause problems, particularly where several SPI devices (SRAM, flash, ADC) are used in different cogs. Locking could always be done at the user (high) level rather than being built into the various drivers or it could be done in the drivers themselves. That's a topic for discussion.
    ### SD Card Profile ###

    Disk Signature: 0x00000000

    Partition 0 - 0xD08EE44F
    C3BOARD FAT16

    512 - Bytes Per Sector
    64 - Sectors Per Cluster
    3841344 - Total Sectors
    60021 - Total Clusters
    19008 - Used Sectors
    3822336 - Free Sectors

    32 KB Stride Speed Test:

    writeByte - 3 KBs
    writeShort - 6 KBs
    writeLong - 9 KBs
    writeData - 23 KBs
    readByte - 3 KBs
    readShort - 6 KBs
    readLong - 12 KBs
    readData - 239 KBs
  • BTXBTX Posts: 674
    edited 2011-05-13 13:18
    Thank you so much Chris.
    Obviously I should read anout I2C specifications.... :)
  • KyeKye Posts: 2,200
    edited 2011-05-13 20:12
    That's a useful version Mike! Thanks,
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-13 22:02
    There are lots of other possible ways to add C3 compatibility. You could put -1 in as the value of the /CS pin number and have a completely separate (C3 only) call to configure the 3 values for the chip select mechanism. That might in fact be preferable. That way, when drivers are written or modified for SRAM or flash or the ADC, the same call with the same parameters could be used in the other drivers.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-14 11:44
    Kye,
    Here's a variation that I'm much happier with. It uses the /CS parameter to FATEngineStart to pass the pin number of the SPI select counter count pin and uses the 3 RTC parameters to pass the pin number of the SPI select counter /clear pin and the select count for the SD card. This leaves one parameter to use for the select count for an optional SPI RTC like the DS3234. This last parameter can be zero if there's no RTC. If there's enough code space in the cog for the RTC code, there might be able to be a single C3 version of the driver that works whether a RTC is present or not.
  • Cluso99Cluso99 Posts: 18,069
    edited 2011-05-14 18:24
    Congratulations Kye. Your code is certainly pleasant to read. I look forward to getting the time to read your app note and also incorporate you SD code into ZiCog.
  • KyeKye Posts: 2,200
    edited 2011-05-15 08:42
    @ Mike Green - Why not just have it so if you pass -1 as the CS parameter it takes values from the 3 unused RTC spots as the values for the COUNT/CLEAR/ and SELECT number? I don't have a C3 to test with but it sounds like that would produce a cleaner version.
  • Mike GreenMike Green Posts: 23,101
    edited 2011-05-15 08:58
    Kye,
    I wanted to allow provisions for a version with a RTC. The SPI select mechanism has two uncommitted lines and it would be easy to add an expansion board with an SPI RTC. The 3rd RTC parameter allows the user to specify the select line for a RTC (or zero if none).
  • BTXBTX Posts: 674
    edited 2011-06-15 14:32
    Hi !! me again

    I'm trying a code with this Full file system driver, and using RTC DS1307 in it.
    Well, all was going fine until now, there is a call into a rutine in my code that calls rtc.clockMinute and I'm getting allways the same minute value, although the RTC clock is working at time after check this issue after a few minutes.
    What could be happend ?

    Some of the code is:
        repeat secuences             
          NroSec := SD.readShort       
          repeat j from 0 to placas-1 
            mandar := SD.readByte     
            MandaSalida(j, mandar)     
          tiempo := SD.readShort      
          ActualizaTimeVariables
          DisplayDec(40, rtc.clockMinute) ' HERE **** I check for the minutes, and I get always the same value.**********
          if apagarHora ==  rtc.clockHour and  apagarMinutos == rtc.clockMinute            
             quit
          Pause(tiempo)
    

    Sorry if some words are in Spanish, anyway I've cut some portion of code, for your convenience to read it.
    Thanks in advance.
  • KyeKye Posts: 2,200
    edited 2011-06-15 14:38
    In the RTC driver you have to call the "readTime" method first to cache new time information. All the time access methods only returned cached values. You must cache new values by calling the "readTime" method.

    The reason for using the "readTime" method is two fold. One: it returns true on success and false on failure so you know if everything worked. Two: It prevents roll over issues from occuring if you were to read each time value one at time - "readTime" caches everything at once.

    Thanks,
Sign In or Register to comment.