• AVR Freaks

Hot!SD card using static SPI

Author
LaserQuest
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2019/03/19 02:28:53
  • Location: 0
  • Status: offline
2019/03/27 04:20:38 (permalink)
0

SD card using static SPI

Does anyone have success using Harmony SD card using STATIC SPI drivers?
 
I am developing code for my PIC32MZ2048EP using Harmony 2.06
 
We have several peripherals which use SPI and up to this point we have had good experience setting up SPI busses with STATIC drivers.
 
However, when I attempted to create a driver for the SD card, which has it's own SPI bus, I had serious difficulty getting it to work at all. The card would never register properly, and observing the signals on the SPI bus I could see the card was never getting out of its 400kHz initialisation state. I could see several instances where the bus was not being driven according to the SD Card spec, and it appeared to me that there were serious flaws in the code.
  • The initial 74 clock pulses should be driven with the CS and MOSI pin high, but the CS pin was low.
  • Waiting for a response from the SD card with the MOSI pin low instead of high.
It was only when closely following project examples which always recommend using DYNAMIC SPI drivers that I had any success, and now I can cheerfully read and write with my SD card at will.
 
However, it would be our strong preference to set the SD card up with STATIC SPI drivers, since we find this very much simpler to debug.
 
Does anyone have any comment on this? Is it proven to be possible to work with the SD Card using STATIC SPI?
 
Many thanks for your time.
 
#1

3 Replies Related Threads

    LostInSpace
    Super Member
    • Total Posts : 229
    • Reward points : 0
    • Joined: 2016/03/11 22:47:59
    • Location: 0
    • Status: offline
    Re: SD card using static SPI 2019/03/28 16:56:27 (permalink)
    0
    Q) Has anyone gotten SD Card to work using Static SPI?
     
    Yes - Here is a post of how I did it,
     
    https://www.microchip.com/forums/m1082928.aspx#1083276

    post edited by LostInSpace - 2019/03/28 16:57:59
    #2
    LaserQuest
    New Member
    • Total Posts : 2
    • Reward points : 0
    • Joined: 2019/03/19 02:28:53
    • Location: 0
    • Status: offline
    Re: SD card using static SPI 2019/03/29 04:26:22 (permalink)
    0
    Thanks - I will dig into that and see if I can get to grips with it.
    #3
    aatifshaikh66
    New Member
    • Total Posts : 27
    • Reward points : 0
    • Joined: 2019/02/20 03:17:39
    • Location: 0
    • Status: offline
    Re: SD card using static SPI 2019/04/01 00:08:03 (permalink)
    0
    not sure about Microchip, but I've implemented SPI based SD card project many times on STM controller.
     
    for reference, you can use SD-card by CHAN. The drivers are pretty easy to understand and port. You can use all the FATFs library as well. All you have to do is to replace or add the SPI drivers with microchip's driver (random function name: SPI_send_date and SPI_receive_date). Furthermore, SD-card works on two different clock-speed (100khz to 400khz during the initialisation process, then you can switch it maximum clock-speed up to 25Mhz). Hence, clock-speed management also required.


    http://elm-chan.org/docs/mmc/mmc_e.html
    http://elm-chan.org/fsw/ff/00index_e.html
    #4
    Jump to:
    © 2019 APG vNext Commercial Version 4.5