• AVR Freaks

Hot!Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing

Author
TS9
Super Member
  • Total Posts : 782
  • Reward points : 0
  • Joined: 2010/05/07 10:52:22
  • Status: offline
2018/08/01 00:25:47 (permalink)
0

Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing

Hi
 
ToolChain:
MPLAB IDE   V4.00
MPLAB XC32  v1.44
MPLAB Harmony  v2.04
Hardware:
PIC32MX795F512L Customized Board
microSDCard     -32GB , 512MB .
 
Is Harmony v2.04 Support (more than 2GB) 32GB Memory Cards  ?
 
I am using SPI2 (RG6,RG7,RG8) with RD2 as SDCard_CS Pin to Interfacing microSDCard with PIC32MX795F512L MCU.
 
I am trying to create .txt from demo
 
C:\microchip\harmony\v2_04\apps\fs\sdcard_fat_single_disk
 
I have changed ........................>              SPI_ID_2
and Chip Selected Port  and Pin   > Port D and Pin 2
Write Protect and Card Detect I have not used .
 
Rest All default ..
I am able to create .txt in MSD Thumb Drive .
But Not able to create .txt in microSD Card (either in 512MB or in 32GB Cards) .
 
I have not created BSP for my customized Hardware .
 
My Hardware in working fine because I am able create .txt with FAT  (Old) without harmony in 32GB SDCard..
 
Please advice..
 
 
--
TS9
post edited by TS9 - 2018/08/01 03:43:28

Attached Image(s)

#1

6 Replies Related Threads

    TS9
    Super Member
    • Total Posts : 782
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing 2018/08/04 07:50:17 (permalink)
    0
    Please Update..
    #2
    Jim Nickerson
    User 452
    • Total Posts : 6124
    • Reward points : 0
    • Joined: 2003/11/07 12:35:10
    • Location: San Diego, CA
    • Status: offline
    Re: Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing 2018/08/04 08:07:17 (permalink)
    0
    Have you opened a support ticket ?
    #3
    LostInSpace
    Super Member
    • Total Posts : 261
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing 2018/08/08 22:24:10 (permalink)
    0
    I just got the SD Card Interface running on several eval boards that I have.
     
    I was able to read and write SanDisk and PNY Micro SDHC cards of 8, 16 and 32 GB.
     
    Here is the path I took.
    1) As has been noted before - the instructions given here work as a baseline demo of how to setup the Harmony Drivers.
    microchipdeveloper.com/harmony:audio-player-lab2
    2) Following the setup in step 1, I ported the app.c from the Harmony demo: "sdcard_fat_single_disk"
     
    I had that working in about 2 hours - As you noted, you have to change the exact pin assignments in the examples to match your hardware - so this proved that I could talk to the SD Card from my demo boards.
     
    Trouble with the step 1 setup for me was,
    1) It uses the SPI with Dynamic drivers
    2) It uses timer 1 as a resource
     
    My existing application uses static SPI and I already use timer 1 for other critical timing tasks.
     
    So I found this application note and code - this code uses FsFat and register access to control the SPI and it uses a timer for timeout.
     
    tutorial.cytron.io/2017/09/17/fatfs-for-pic32mxmz/
     
    I studied this example and ported the SPI calls (what few there were) with PLIB_SPI commands. I didn't port the timeout timers (so they never timeout, but if everything works, you never timeout anyway - use at your own risk).
     
    That took about 4 hours to get working. At this point I was able to drop in the latest FatFs code from the original website (elm-chan.org) and that just worked in a few minutes.
     
    In summary I found FatFS to be pretty easy to use and had it wired up to my original working application in less than a day.
     
    HTH.
    #4
    TS9
    Super Member
    • Total Posts : 782
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing 2019/07/17 06:32:21 (permalink)
    0
    Hi  LostInSpace,
     
    Will it possible to interface Two SDCards with FATFS ? 
     
    Thanks.
     
    --
    TS9
    #5
    LostInSpace
    Super Member
    • Total Posts : 261
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing 2019/07/17 12:03:37 (permalink)
    0
    >>>>>Will it possible to interface Two SDCards with FATFS ? 
     
    Indirectly - FatFS holds information about the specific card when you open it. So that would be a problem to try to use the same driver twice. If I needed to do this I would create two driver instances by duplicating the files and name all the instance files, variables and structures like: '_1' and '_2'.
     
    It is totally brute force, but it should not take that much time to do. Other solutions are naturally possible.... Your Mileage may vary.
     
    Hope this helps.
    #6
    TS9
    Super Member
    • Total Posts : 782
    • Reward points : 0
    • Joined: 2010/05/07 10:52:22
    • Status: offline
    Re: Harmony : PIC32MX795F512L microSDCard (> 2GB) Interfacing 2019/07/21 06:41:25 (permalink)
    0
    SteveHageman
    >>>>>Will it possible to interface Two SDCards with FATFS ? 
     
    Indirectly - FatFS holds information about the specific card when you open it. So that would be a problem to try to use the same driver twice. If I needed to do this I would create two driver instances by duplicating the files and name all the instance files, variables and structures like: '_1' and '_2'.
     
    It is totally brute force, but it should not take that much time to do. Other solutions are naturally possible.... Your Mileage may vary.
     
    Hope this helps.


    Hi..
    Thanks for suggestion ..
    But will it possible to link or mount without brute force method..

    ReturnSDCard_1 = f_mount(&SDCardFatFs_1, (TCHAR const*)SDCardPath_1, 0);
    ReturnSDCard_2 = f_mount(&SDCardFatFs_2, (TCHAR const*)SDCardPath_2, 0);

    if(( ReturnSDCard_1 != FR_OK))
    {
    /* FatFs Initialization Error */
    Error_Handler();
    }
    if(( ReturnSDCard_2 != FR_OK))
    {
    /* FatFs Initialization Error */
    Error_Handler();
    }
    /*
    ReturnSDCard_1 = f_open(&SDCardFile_1, "0:JABC.TXT", FA_CREATE_ALWAYS | FA_WRITE);
    ReturnSDCard_2 = f_open(&SDCardFile_2, "1:KHELLO.TXT", FA_CREATE_ALWAYS | FA_WRITE);
    |
    |
    |
    /*##-6- Close the open text files ################################*/
    f_close(&SDCardFile_1);
    f_close(&SDCardFile_2);
     
     
    #7
    Jump to:
    © 2019 APG vNext Commercial Version 4.5