FatFs + SDHC data logger with KSDK in Kinetis Design Studio

Document created by Jorge_Gonzalez Employee on Jun 24, 2015Last modified by Diana Torres on Feb 28, 2017
Version 2Show Document
  • View in full screen mode

Hello KSDK friends:

 

This time I want to share with the community a project using FatFs and the SDHC + I2C drivers provided with the Kinetis SDK platform. This is a baremetal project with no RTOS.

 

If you are a follower of colleague Erich Styger's MCU_on_Eclipse blog, then you might be familiar with the demo application, which consists of a data logger to store the accelerometer values of a FRDM-K64F on-board FXOS8700CQ (accelerometer/magnetometer) to a Micro SD Card.

 

The difference is that this demo project is implemented with KSDK v1.2 platform, using the next components:

 

- FatFs: Generic File System used in embedded systems.

- SDHC peripheral driver: To handle the SD Card commands.

- SD Card driver: Part of the KSDK composite drivers.

- I2C peripheral driver: Used to communicate with the on-board FXOS8700CQ.

- other peripheral drivers and systems: Clock System, GPIO driver, etc.

 

2 attachments are included with this post:

 

1) Demo project for KDS (created with KDS v3.0.0).

2) Document with a detailed description of how the project was created.

 

If when importing the project KDS asks you to add compiler search paths, just select "No". Paths are already configured.

 

IMPORTANT: The project can be placed in any location, but the next conditions must be met before building the project:

 

- Build the K64F KSDK platform library KDS project. The "Debug" build configuration is used. If not familiar with this, please refer to "Getting Started with Kinetis SDK (KSDK) v.1.2.pdf" in KSDK doc folder: C:\Freescale\KSDK_1.2.0\doc.

 

- Check that the build variable {KSDK_PATH} is pointing to your KSDK v1.2 installation (Project -> Properties -> C/C++ Build -> Build Variables):

 

KSDK_PATH.png

 

 

RUNNING THE DEMO

 

1- Load the application to the FRDM-K64F.

2- Connect the PC to the FRDM-K64F OpenSDA micro USB port.

3- Open a terminal software and connect to the OpenSDA Virtual COM port. Configure the terminal for a baud of 115200.

4- Reset the board. You will see this message:

 

 

5- Insert micro SD Card. Now terminal should look like this:

 

 

6-  Accelerometer values will start to be printed to terminal and logged to SD Card each second.

 

A safe remove mechanism is implemented. Press SW3 in FRDM-K64F until you see the message shown below:

 

 

Keep SW3 pressed until SD Card is removed.

 

7- Now with a PC you can open the file LOG_DATA.txt:

 

 

The file can also be opened by a software such as Excel to graph the results:

 

 

I hope you like this demo!

 

Regards.

Jorge Gonzalez

Outcomes