Menu

SD card code sample needed

ofuzzy1
2018-04-10
2018-04-12
  • ofuzzy1

    ofuzzy1 - 2018-04-10

    Hi Folks,

    Been working a new job, 3 years, and this first chance I've had to tinker on a project.
    I am really appreciative of all the hard work you have put into the GCB. Thanks!

    I need to write to a SD card, <4G is fine.

    Does anyone have a working code sample?

    E.V. I have some code snippets I'll be send you soon, and a cool board.

    BTW my favoite chips are:
    Pins
    8 12f1840
    14 16f1825
    20 16f1829
    28 18f2xK22
    28 18f2xj53
    40 18f4xK22
    40 18f2xj53

    x=5,6,7 (ram/prog)

    Cheers,
    Perry

     
  • Anobium

    Anobium - 2018-04-10

    We have read code for MS-DOS structures. Full operating system file support but for read-only.

    We have write code for Block structure, I think there is also write blocks code.

    So, you need write. Use the Block write code. It is easier to use. For this code do a search of the forum - I think Kent (probably wrong) developed it.

     
  • kent_twt4

    kent_twt4 - 2018-04-10

    The SD_565.h file found here https://sourceforge.net/p/gcbasic/discussion/629990/thread/bf896980/#fba3 was probably the last sd library that I posted. It mostly initializes the SD card, performs card reader type functions/displays on a terminal, and reads back bitmap files that have been placed on the card via manual download from PC.

    The library has the CMD24 block write procedure, it is commented out awaiting further development, but it worked to the best of recollection. Some notes:

    1. The write block buffer data array is set to128 bytes, with the rest of the block filled with dummy 0x00's, should be 512 for full use of the block size. The development started with using a smaller size PIC. I would use a 18f26k22 as a minimum for sd library.
    2. The SD card should formatted say with FAT16 for standard capacity card, FAT32 for high capacity card. Start with a clean card, and drop a smaller size text or bitmap file on it for debug purposes.
    3. The debug functions should be used initially to make sure sd card is initializing and communicating properly. Also the Debug_SD_FileAttributes will discover address locations and file sizes.
    4. An important thing to realize is that there is no dynamic file directory address awareness built into the write block procedure. This could be calculated from the file directory debug, or just start the logging? or write file to a safe address location beyond the file directory or test file address.

    EDIT: Be sure to download the SD-Library.zip for read and display bmp example, debug screen grabs, but use the newer SD_565.h

     

    Last edit: kent_twt4 2018-04-10
  • ofuzzy1

    ofuzzy1 - 2018-04-12

    Thanks Guys, You're the best.

     

    Last edit: ofuzzy1 2018-04-12

Log in to post a comment.