element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet & Tria Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • About Us
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      • Japan
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Vietnam
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs [FRDM-K64F + Kinetis Design Studio (KDS)+Processor Expert(PE)] Accessing SDCARD through K64 board
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: bheemarao
  • Date Created: 27 Feb 2015 11:27 AM Date Created
  • Views 770 views
  • Likes 0 likes
  • Comments 0 comments
  • processor_expert
  • kds
  • sd-card
  • frdm-k64
Related
Recommended

[FRDM-K64F + Kinetis Design Studio (KDS)+Processor Expert(PE)] Accessing SDCARD through K64 board

bheemarao
bheemarao
27 Feb 2015

Here is a project created to interface and explore how to access the SD-Card slot available onboard with K64F freedom board.

Before we start this project below are the pre-requisites:


  1. KDS software tool from Freescale
  2. FRDM-K64F Freedom development board
  3. Micro-SD-Card ( I am using 1GB)

 

I have created a project by name “SDCARD access using PE”

 

image

 

Next select the device: you have 2 options for selecting it, one is by “Boards” and other is by “Processors” i am selecting it from the “Boards” option.

 

image

 

Select the board part number FRDM-K64 and proceed further

Make the selection of processor expert in standalone as shown below:

image

 

Click finish.

Now click on Processor component


image


 

And make the clock configuration as shown below:

 

image

 

 

Next change the clock configuration-3 as shown below

 

image

 

Now we will proceed further by adding our components:

Select component library and select FAT_FileSystem

 

image

 

It will ask for you to add the shared components as shown,

 

image

 

Next select “Real time clock” as shown

 

image

 

Now it will create corresponding components in our components window


Now you can see the different shared components created for FAT_FileSystem

image

 

We need to make the corresponding settings for these components as you can see a red cross on it which indicates it has error in settings.

We will go for SD_Card settings

 

image

 

By clicking on slave select pin it prompts for LDDSS where you need to assign hardware pin PTE-4 as shown:

 

image

 

Next coming to TimeOut component, click on it.

 

image

 

Now coming to next component, i.e SPI Master


SD-card is connected through SPI interface so we need to assign the spi block and its corresponding pins for it.

Here the K64 board is connected to SD card slot via SPI-1

 

image

 

Select the input pin connect to PTE-1 as shown

 

image

 

Next output pin connect to PTE-3 as shown

 

image

 

Next clock pin connect to PTE-2

 

image

 

And there is no chip select used hence make it zero by clicking on “-“ button

Now the SPI interface looks as below:

 

image

 

And make the auto initialization radio button to on by clicking the check box.

 

image

 

 

Now need to select the clock rate speed required for SPI interface.

Make the settings as show below:

 

image

Now we need to add the component ‘Utility’ this is required for commonly used utility methods, especially safe string copy/concatenation routines.

image

 

Next add the ConsoleIO component module from component library as shown below:

 

image

image

Double click on the module component to add to our project:

Next select UART0 window from pin configuration main menu as shown below:


As UART0’s RX is connected to PTB16 and UART’s TX is connected to PTB17.

This UART port pins are required for console terminal output.

image

Next click on ConsoleIO_Serial_LDD button as shown below:

image

We have configured UART0 as shown below:


image

Now generate the project by clicking the below shown button

image

It Builds with no errors as shown below:


image

 

Now we are going to add our code in “main.c” file

 

 

 

PORT_PDD_SetPinPullSelect(PORTE_BASE_PTR, 6, PORT_PDD_PULL_DOWN);

PORT_PDD_SetPinPullEnable(PORTE_BASE_PTR, 6, PORT_PDD_PULL_ENABLE);

 

          if (FAT1_Init()!=ERR_OK) { /* initialize FAT driver */

ERR_IDLE;

             }

 

          if (FAT1_mount(0, &fileSystemObject) != FR_OK) { /* mount file system */

               ERR_IDLE;

             }

 

 

          if (FAT1_open(&fp, "./Test_K64.txt", FA_OPEN_ALWAYS|FA_WRITE)!=FR_OK) {

                            ERR_IDLE;

                           }

                        // move to the end of the file

 

          if (FAT1_lseek(&fp, fp.fsize) != FR_OK || fp.fptr != fp.fsize) {

                              ERR_IDLE;

                        }

 

 

 

           for(cnt=0;cnt<=10;cnt++) {

 

           printf("x y z values are X: %d  Y:  %d Z:  %d\n", x,y,z);

 

 

UTIL1_strcat(write_buf, sizeof(write_buf), (unsigned char*)"\r\n");

UTIL1_strcat(write_buf, sizeof(write_buf), (unsigned char*)"Bheema \t ");

UTIL1_strcatNum16s(write_buf, sizeof(write_buf), x);

UTIL1_chcat(write_buf, sizeof(write_buf), '\t');

UTIL1_strcatNum16s(write_buf, sizeof(write_buf), y);

UTIL1_chcat(write_buf, sizeof(write_buf), '\t');

UTIL1_strcatNum16s(write_buf, sizeof(write_buf), z);

UTIL1_strcat(write_buf, sizeof(write_buf), (unsigned char*)"\r\n");

 

if (FAT1_write(&fp, write_buf, UTIL1_strlen((char*)write_buf), &bw)!=FR_OK) {

ERR_IDLE;

}

 

}

 

           /* closing file */

 

(void)FAT1_close(&fp);

FAT1_Deinit();

 

 

Now it’s time to build the project, click on the hammer button as shown

 

image

 

You can see the build is finished successfully with no errors

 

image

 

Now it is ready to debug/execute


Click on Debug configuration as shown below:

 

image

 

 

Now connect the K64 board to OPEN SDA port to your computer through USB cable, Then click on Debug button. And insert a SD-Card in the slot as shown below

 

 

image

 

You can see below Debug window screen

 

image

 

Make sure you have open the corresponding hyperterminal window from your ‘Computer Management’ Device manager window:

In my case it is connected to COM23 port

 

image

 

Now click on green ‘Resume’ button

 

image

 

Open COM23 port from any of the hyper terminal application (putty in my case)

 

image

 

The output seen in the terminal is as shown below:

 

image

 

 

The output seen in the sd-card

Remove the sdcard from K64 and access it through card reader and explore the contents, it will show the new file created  “TEST_K64.TXT” as shown below:

 

image

 

 

The content of this file is as shown below:

 

image

I have enclosed the project folder and srec file for quick overview and you can directly test the program by programming the SREC file

 

Happy SDCard exploring  image image image

Attachments:
SDCARD access using PE.rar
SDCARD access using PE.srec.zip
  • Sign in to reply
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2026 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube