Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 5 of 5

Thread: Slow SPI needed for old SD Card module

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Location
    Bavaria, Germany
    Posts
    3

    Slow SPI needed for old SD Card module

    Could someone advise/guide me on how to setup a slow SPI clock using the SPI lib on a Teensy LC for <400kBaud rates?

    I wish to use a 'slow' SD Card module (from 2004! :/) on a Teensy LC. (I often like trying stuff out of my old scrap collection)

    The spec describes: synchronous 8-bit data transmission, MSB first. For initialization <400KBaud. A clock cycle is also required to read in data from the memory cards, possibly by outputting a dummy byte.

    Many thanks

    Peter
    nb. My first post. Thanks for your patience in advance

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    24,229
    Have you tried using the existing SD library? I'm pretty sure it does initialization at slow speed for compatibility with these sorts of cards.

    But if you *really* want to dive into writing your own SD card access code, to answer your original question, you would use SPI.beginTransaction with SPISettings specifying 400000 for the max clock speed. This same approach is used regardless of the clock speed. There is nothing special about configuring slow speeds. You simply use a smaller number of the max speed in SPISettings.

  3. #3
    Junior Member
    Join Date
    Apr 2021
    Location
    Bavaria, Germany
    Posts
    3
    Quote Originally Posted by PaulStoffregen View Post
    Have you tried using the existing SD library? I'm pretty sure it does initialization at slow speed for compatibility with these sorts of cards.

    But if you *really* want to dive into writing your own SD card access code, to answer your original question, you would use SPI.beginTransaction with SPISettings specifying 400000 for the max clock speed. This same approach is used regardless of the clock speed. There is nothing special about configuring slow speeds. You simply use a smaller number of the max speed in SPISettings.
    I did try using the ReadWrite (Mellis/Igoe) example form the SD library reference page. Always gave "Initialization failed! ".

    Used "as is", viz. same I/O pins numbers (matched the LC). I haven't changed/re-set via an SPISettings() call. I need study this, will re-try and report back.

    The SD module's manual is uploaded below - sorry - it is in German - but does provide the circuit diagram along with components list.
    p.6 describes; the module's 10-way IDC header, JP1 switches its Vcc for 3V3 or 5V. JP1 pins 1 & 2 are linked and I feed module's 3V3 from a external 3V3 reg (TI LM1117-3.3).
    Connectivity became
    MOSI0 - LC-pin 11 -> SD-pin 7 (DO)
    MISO0 - LC-pin 12 -> SD-pin 3 (DI)
    SCK0 - LC-pin 13 -> SD-pin 6 (SCLK)
    "CS" - LC-pin 4 -> SD-pin 5 (CS)

    Many thanks Paul
    Peter
    Attached Files Attached Files

  4. #4
    Senior Member
    Join Date
    Jul 2014
    Posts
    3,159
    Quote Originally Posted by OldGuy1946 View Post
    MOSI0 - LC-pin 11 -> SD-pin 7 (DO)
    MISO0 - LC-pin 12 -> SD-pin 3 (DI)
    r
    should that not be inverted: MISO Master In Slave OUT (DO of SD)?

  5. #5
    Junior Member
    Join Date
    Apr 2021
    Location
    Bavaria, Germany
    Posts
    3
    Bingo! Thank you WMXZ!!
    Sorry my setup error!

    Swapped over the MOSI0 and MISO0 links to the SD card module and the original SD ReadWrite example ran responding with "Initializing SD card...initialization done."

    Many thanks to WMXZ and Paul and to those who kindly applied their thoughts and thus their time.

    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •