Added Micro SD Card Socket to FRDM-K22F

Probably for cost reasons, the Freescale FRDM-K22F does not come with the micro SD card socket populated on the the board:

freescale-frdm-k22f-board with no SD card socket

Freescale FRDM-K22F Board with no SD card socket

With a little soldering skills it is possible to populate the socket so the board can be used with a file system on it :-):

Using SD card with FRDM-K22F Board

Using SD card with FRDM-K22F Board

Molex SD Card Socket

The first thing is to get the SD card socket. It is the same one we use for the tinyK20 board (see “tinyK20: New Board with micro-SD Card“). The SD card socket is the SD-105027-001 from Molex: http://www.molex.com/pdm_docs/sd/1050270001_sd.pdf

Molex SD-105027-001 Socket (Source: Molex Data Sheet)

Molex SD-105027-001 Socket (Source: Molex Data Sheet)

It costs around $1 (depends on quantity), e.g. from Mouser Electronics here.

Adding the SD Card Socket to the Board

As the SD card socket pads already have some solder on it, it is possible to place the socket on it and then heat the solder with a soldering iron. What works best is to add little solder paste, then put the socket on it (it gets ‘glued’ by the paste) and then head the pads.

The most difficult pads are the four ground corner pads as underneath the socket. But there is some space to place a thin soldering tip and to heat the pads:

SD Card Ground Pads

SD Card Ground Pads

The ‘front’ pads get soldered easily:

Soldered SD card socket

Soldered SD card socket

With this, I can read/write to the SD card:

Using SD card with application

Using SD card with application

The example above is from my “Kinetis Drone” Kinetis Design Studio project, and the project is found on GitHub here.

Summary

Adding a SD card socket to the board extends the usefulness of the board. So I can use it as a data logger or by any other means to read/write data to a SD card.

An example project is on https://github.com/ErichStyger/mcuoneclipse/tree/master/Examples/KDS/FRDM-K22F/FRDM-K22F_FatFS.

Happy Soldering đŸ™‚

Links

32 thoughts on “Added Micro SD Card Socket to FRDM-K22F

  1. Pingback: FRDM-K22F ARM Board doesn’t have an SD Card Socket? Not so Fast! | Hackaday

  2. Very cool! Any luck implementing / accessing the SD card via USB as a MSD device? Would the FSL component have support for this as well as a composite enumeration of MSD + CDC?

    Like

    • Hi Nate,
      it is less about luck, but more about the amount of time available. I did not had much available at all in the recent weeks, so no, I had no chance to work on such a project. And the FSL_USB_Stack component currently does not implement a composite device yet.

      Like

      • Hey Erich,
        Can certainly understand, everything for an engineer is always a battle of time. I noticed there is an example of MSD device as well as composite MSD + CDC in the kinetis SDK examples for the K22. Tempted to give that a try though I haven’t tinkered around with Kinetis SDK yet.

        Like

    • Hi Bob,
      are you using the latest McuOnEclipse components from SourceForge? There has been an issue with the latest Processor Expert version around the Init_USB_OTG, but I was under the impression that this has been fixed. Can you provide more details.

      Like

  3. Hey Erich,

    Could you please help me in getting the SD Card interface working with a FRDM-K22F?

    I’m running the latest KDS with KSDK 1.3. I’ve downloaded and installed your latest “my components” library and tried to install both “SD_Card” and “FAT_FileSystem” but I get hung up on it wanting to install “HWSPI”. I’ve been looking around for it forever with no luck.

    Also, Any suggestions on how to best solder the Molex uSD Card Socket? I can get the four data lines along with power and ground but the card detect pin never seems to work.

    Thanx,

    myke

    Like

    • Hi myke,
      have you created that project with the Kinetis SDK enabled? The problem is that the SDK is not compatible with all components, so I have created my project *without* the SDK.
      As for the card detect pin: keep in mind that the pin is HIGH active so you need to have a pull-down. I’m using internal pull downs:
      /* SD card detection: PTB16 with pull-down! */
      PORT_PDD_SetPinPullSelect(PORTB_BASE_PTR, 16, PORT_PDD_PULL_DOWN);
      PORT_PDD_SetPinPullEnable(PORTB_BASE_PTR, 16, PORT_PDD_PULL_ENABLE);
      I hope this helps. Otherwise check out my Kinetis Drone project (link in the article), although that project has many other functions. Maybe I should create an SD card only project for the FRDM-K22 if there is a good demand (and I find time).

      Like

  4. Hi Erich,

    Thank you for getting back to me.

    On the socket issues, I ended up making a little application that has all the pins pulled down and is polling them. I touch a wire to the pins to see that they are connected. What I’ve found is that the Vdd pin is very difficult to connect to. So, this is not an issue – is there somewhere I can post the application so that other people can use it (I can also put it up on the FSL/NXP Community site).

    Yes, I’ve been creating all my projects with KSDK.

    I’ve just started an application with “FAT_FileSystem” This pulled in:
    – SD_Card
    – GenerticTimeDate
    – HWSPI (I selected “New component [My Components/HWSPI]…” – correct?)
    – CS1
    successfully.

    Now, it looks like I have to go through the various configurations. I’ll try a bit of it but I do have two questions for you:

    1. Do you have a sample configuration for the K22F? If it’s in your drone project, how do I extract them?
    2. For my application, I will want to connect using the FSL_USB_CDC_Device but for initial setup/debug, I would like to use something like like “fsl_debug_console” which I guess is no longer available. What do you have in “My Components” that provides this functionality?

    Thanx,

    myke

    Like

    • Hi Erich,

      Just going through the Entries.

      For “SM1:SynchroMaster[HWSPI]” which came up automatically and has an error indicator (“x”) in it, I put in the following properties:
      Channel: SPI0
      Settings:
      Input Pin: PTD3
      Output Pin: PTD2
      Clock Pin: PTD1

      Shift clock rate/CS to CLK delay/CLK to CS delay: I have no idea what to put in here and I’m surprised that everything is running off of Clock0 when I click on them.

      For “SMasterLdd1:SPIMaster_LDD I have an error indicator and under properties, I have the same errors as for SM1.

      Now, I don’t see anywhere to specify Chip Detect (although looking at the APIs, I suspect that the application polls for the device to be present (“isDiskPresent”) and then mounts it – correct?

      So, I’m looking for:
      1. The missing clock/delay specifications along with how the Chip Detect and Chip Select are specified.
      2. An example app/code to show how an SD Card is accessed.
      3. How to pass execution logging information through the programming port.

      Thanx – sorry for the questions,

      myke

      Like

      • Thanx Erich – I’m looking forward to what you come up with.

        It must be frustrating with the different software versions that have come out over the past 3-4 years.

        I appreciate the responses/help.

        myke

        Like

      • Hi Erich,

        Just got the code, tried to build it and have a number of missing .h files.

        ie in main.c, the first ones missing are:
        – Cpu.h
        – pin_mux.h
        – LED1.h
        and so on.

        Do I need to update the Project Settings and, if so, where do I find the .h files? They aren’t part of the GitHub package.

        Thank you and sorry it’s not easy,

        myke

        Like

        • Hi myke,
          this is a Processor Expert project, so the generated files are not in the repository. You need to generate code first (right click on the .pe file and select ‘Generate code’.

          Like

      • Hi Erich,

        I got the downloadable .zip from: https://github.com/ErichStyger/mcuoneclipse and then expanded and copied the the entire “mcuoneclipse-master” onto my hard file.

        Next, I imported the “FRDM-K22F_FatFS” from mcuoneclipse-master\Examples\KDS\FRDM-K22F

        I then did the “Generate PE” and nothing seemed to happen so I tried to build again and got:
        “Please confirm creation/update/deletion of the following static project files:” with all the files I had.

        So, Clicked OK and then got the following errors:
        Events.c – No such file or directory for “Cpu.h”
        main.c – No such file or directory for “Cpu.h”
        Platform.h – No such file or directory for “PE_Types.h”
        USB0_Init.c – No such file or directory for “Init_Config.h”
        CPU_Init.c – No such file or directory for “PE_Types.h”
        Peripherals_Init.c – No such file or directory for “Init_Config.h”
        Vectors.c – No such file or directory for “PE_Types.h”

        Sorry, any ideas of what I’m doing wrong?

        myke

        Like

        • Hi myke,
          not sure what is going wrong on your side :-(. Sometimes I have seen strange things, and exit Eclipse and starting Eclipse has solved that.
          In any case: I have posted the project with all generated source in the NXP forum.
          Erich

          Like

      • Hi Erich,

        Sorry I’ve been quiet on the issue – I’ve been working through this on my own and I have posted a console interface with full read-write capability.

        I’d like to ask you if you have tested your WRITE_MULTIPLE_BLOCK code – there seems to be some confusion on how the stop token works and it seems to me that it does not return a 0xE5 byte like the other token commands (it just returns 0xFF after it is executed). Your SD1_SendCmd code is basically identical to the “Generic” example from ChaN’s website, but when I tried to get it working, I found that 0xE5 is never returned after the 0xFD token is sent. Looking at other examples, I discovered that the 0xFD token is just sent but nothing is checked.

        I’m going to follow up with ChaN on this issue.

        Thanx for your help and sorry I’ve been quiet – I had a number of issues to resolve (the 0xFD token being one of them) as well as a few distractions.

        myke

        Like

        • Hi Myke,
          I had issues in the past with some devices using the block transfer method. I was running out of time, and was not able to check the root cause, so I ended up disabling it so I could look at it later.
          I hope I really could do that soon.
          Erich

          Like

  5. Hi Erich,
    Thanks again for always promptly replying – your a lifesaver.

    I downloaded the source ( for FRDM-K22F-FatFS) from github, and then imported that project into my KDS 3.2 workspace. I then changed the SPI bits and LED bits so they matched my custom board, which is also a K22.
    Compiles are runs! and works!
    I then changed the shell default output to be the RTT as I don’t have a RS232 level converter on this board (or what I now like to use instead, a Sparkfun BOB-12731 TTL serial to USB converter), and that also worked first time! (Really amazed how there were pretty much no problems doing this!)

    Couple questions though:
    The Shell interpreter responds when I type ‘help’ or ‘status’.
    But all the other commands don’t work because I don’t understand what syntax it wants –
    Okay, I just figured out that I need to type ‘FAT1 dir’ to get the directory. (case sensitive)

    The RTT Viewer seems to respond to me typing really slowly, and it looks like backspace is not handled. Am I doing something wrong with the RTT component or RTT_viewer program?

    Can I use TeraTerm to connect to some telnet port instead of using RTT_Viewer? I have someone who wants to use different fonts in his debug window.
    Would it be 127.0.0.1:2333 ? (or :2332?)

    Thanks!

    Brynn

    Like

    • Hi Brynn,
      the usual commands are like the module name follwed by ‘status’ or ‘help’, for example ‘FAT1 status’. And yes, the commands are case sensitive.
      For me the RTT viewer is very fast. And yes, the backspace is not handled as far as I know in the RTT viewer.
      Because RTT does not create a virtual COM port on the host, you cannot use a normal terminal program with it. You might submit such a wish to Segger so they might consider it in the future?
      Erich

      Like

  6. Hi Erich,
    Actually according to the RTT_Viewer help page you can just use telnet to connect, I tried it with TeraTerm and it works.
    (Maybe TeraTerm doesn’t qualify as a ‘Normal’ terminal program, because it can do telnet and ssh)

    From the RTT_Viewer help page:
    The simple way to communicate via the Terminal (Channel 0) is to create a connection to localhost:19021 with a Telnet client or similar, when a connection to J-Link (e.g. via a debug session) is active.

    I just finished writing shell parser commands for the Kinetis RTC component so I can read and set the K22’s on-chip RTC using shell commands. I started with your TmDt component code and modified. I don’t know how to get it into a component, so I’ll just send it to you after a little more testing.
    Also, at the moment I still have to include the TmDt component with my FATFS because it (the FATFS component) doesn’t let me pick the Kinetis RTC component.
    Brynn

    Like

  7. Pingback: First tinyK22 Board with NXP K22FN512 ARM Cortex-M4F | MCU on Eclipse

  8. Pingback: Tutorial: Maximum Clock Frequency for Kinetis using MCUXpresso Clock Tools | MCU on Eclipse

  9. Pingback: FatFS, MinIni, Shell and FreeRTOS for the NXP K22FN512 | MCU on Eclipse

  10. Pingback: How to get Data off an Embedded System: FatFS with USB MSD Host and FreeRTOS Direct Task Notification | MCU on Eclipse

  11. Pingback: tinyK22 Board Rev 1.3 released | MCU on Eclipse

What do you think?

This site uses Akismet to reduce spam. Learn how your comment data is processed.