FRDM K64F Data Logger using FatFs with KSDK 1.2.0

Check out the article by Wesley Hunter about how to use the FRDM-K64F as a data logger. He describes all the steps how to use the Kinetis SDK v1.2.0 with FatFS.

Happy Logging 🙂

Centaurian

This blog is a guide on how to setup using the FatFs library included with the Kinetis SDK 1.2.0 using mostly the Processor expert within Eclipse Luna. FatFs is a generic FAT file system module for small embedded systems written by Chan. I prefer to use Processor Expert when possible as this will often generate code that is smaller in size than using the KSDK library files direct. I experienced many gotcha’s and complication setting this up and wanted to share how I finally managed to get it to work.

  1. Prerequisites
  2. Create New Project
  3. Open Processor Expert
  4. Add SD card component
  5. Add Init_Port component
  6. Add GPIO component
  7. Configure the clock
  8. Import FatFs
  9. Add Card detection code
  10. FAT file appender function
  11. Disable the MPU

Prerequisites

Before you begin please make sure your development environment is setup and you can already compile and debug code using KSDK 1.2.0 on Eclipse Luna…

View original post 2,197 more words

Advertisements

5 thoughts on “FRDM K64F Data Logger using FatFs with KSDK 1.2.0

  1. Pingback: Added Micro SD Card Socket to FRDM-K22F | MCU on Eclipse

  2. Hey there,
    I’m currently working on a K64F based board running freeRTOS tasks. I’m trying to use the SD card for data logging through SPI1, but my data logging service is apparently interrupting the UART interruptions too often.

    I’m using KSDK 1.3’s fatfs files provided in “..\KSDK_1.3.0\middleware\filesystem\fatfs” with fsl_sdspi_disk and fsl_sdcard_spi (..\KSDK_1.3.0\platform\composite\src\sdcard). Inside the fsl_sdspi_disk I use the EDMA for the SPI1 communication. Because the fatfs gives me a limitation of a minimum transfer block size of 512KB, I had to change the SPI1_IRQHandler in fsl_dspi_edma_irq.c to use DSPI_DRV_IRQHandler(SPI1_IDX) instead of DSPI_DRV_EdmaIRQHandler(SPI1_IDX) – therefore I’m not using the EDMA for receiving data, right?

    Because I’m not using EDMA to receive data, due to block size limitation of the fat, I believe that the SPI is interrupting the UART too often – it initializes the sdcard with 700KHz and then it goes to +1MHz. I’d like to know if there’s any work around to fully use the EDMA to communicate with an SD card. My application is using three UARTs with baud rates of 4800, 9600 and 19400 bps – those UARTs have polling reception because they receive variable string length.

    Best Regards,

    Like

  3. Hi Erich,

    I downloaded SDK 2.2 to use with MCUXpresso in hopes to learn how to use the SDCard and FatFS features using a TWR-K64F120M board.

    However, when I try to execute the demo project sdcard_fatfs that comes with the SDK download I get as far as the f_mkfs() and it returns an error. I figured that perhaps it had something to do with the fact that I formatted the card already with Windows. So, I moved it forward to the f_mkdir() line and that returns a failure as well.

    Are you familiar with why this is and do you have any suggestions for what I could do to fix it?

    I hope it is ok that I’m asking as a comment to this thread but I have been unable to find another thread that covers my particular issue.

    Regards,

    TJ

    Like

    • Hi TJ,
      you don’t have to format the card with f_mkfs() if you have formatted it already on Windows. It is recommended to use the Panasonic (Windows) format utility, but it always worked for me with normal Windows formatted devices too.
      It might be a better start for you if you are not using the SDK and if you are using the Processor Expert component(s) instead.
      I hope this helps,
      Erich

      Like

What do you think?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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