SD Card SPI mode w/ FRDM KL-26Z

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

SD Card SPI mode w/ FRDM KL-26Z

2,175 Views
jhnlk
Contributor I

Hey,

I need to develop a data logger using an Arduino SD Card Module Slot (http://bit.ly/1jq3gRJ).

I have chosen the following connections:

PCS: PTD4

SCK: PTD5

MOSI: PTD6

MISO: PTD7

I21SDA: PTA4

I am unsure how to write code to read data to the sd card. Is there a tutorial or some code I can use to implement in my design?

Thanks for your help.

0 Kudos
11 Replies

1,125 Views
mjbcswitzerland
Specialist V

Hi

What is the I21SDA: PTA4 for?

Regards

Mark

0 Kudos

1,125 Views
mjbcswitzerland
Specialist V

Hi

I have an application that runs on the FRDM KL26Z, connecting via the specified pins

PCS: PTD4

SCK: PTD5

MOSI: PTD6

MISO: PTD7

to an SD-card (SREC to load with CW flash utility via OpenSDA) - http://www.uTasker.com/freescale/uTasker_V1.4_FRDM-KL26Z_SD_CARD.srec

There is a UART at 115k on the OpenSDA virtual COM port with a menu allowing a DOS like interface to the file system on the SD card (allowing listing and creating directories, renaming and formatting disks etc.).

When the application USD connector is connected, the board appears as a disk drive to the PC so files can be read and written, etc.

There is a difference to a KL25 application due to the fact that the KL26 has a more advanced SPI interface, with optional FIFO operation. Its register contents are essentially compatible with the KL25 SPI BUT they are not on the same addresses, therefore the memory map used by the SPI driver needs to be adjusted accordingly.

Regards

Mark

The file sytsem used is described in http://www.utasker.com/docs/uTasker/uTasker_utFAT.PDF

The USB driver used is described in http://www.utasker.com/docs/uTasker/USB_User_Guide.PDF

0 Kudos

1,125 Views
jhnlk
Contributor I

A calculation is being performed within the microcontroller and that value needs to be stored to a SD card. My code needs to wait until called before adding data to a file on an SD Card. How would your .srec file do that?

0 Kudos

1,125 Views
mjbcswitzerland
Specialist V

John-Luke

The SREC is a general purpose application allowing you to check HW connections and basic functionality. Of course it is not doing the calculation that your project will need.

The complete code is available at KINETIS Project Code and you can then add your calculation as required. There are detailed user documenst for the SW components (see previous link) and several videoas showing how to use it; eg. uTasker for Kinetis using CodeWarrior - YouTube

Regards

Mark

0 Kudos

1,125 Views
jhnlk
Contributor I

I have code for the calculations but I want to write to the SD card without connecting through a computer. This program seems to require a connection to a computer to operate.

0 Kudos

1,125 Views
mjbcswitzerland
Specialist V

Hi

The program is an example of using the SD card with the KL26:

- Files can be written to the SD card from the PC (when connected via USB and visible as an external hard disk).

- They can be created and written to via the DOS-like interface (command line menu via UART).

- They can also be written from code using the utFAT interface.

Therefore a computer is required to do quick tests with the program and the board but is not needed for an application that just wants to write to the SD card.

Regards

Mark

0 Kudos

1,125 Views
BlackNight
NXP Employee
NXP Employee

1,125 Views
stmevaleval
Contributor I

Hi Erich Styger,

What are the SPI pins used to configure FRDM-KL26Z board as master and is there any example code is already configured for SPI on FRDM_KL26Z board(SD-card slave read/write).

I gone through the  Arduino Data-Logger Shield with the FRDM-KL25Z Board | MCU on Eclipse link, but it was specific to the FRDM_KL25Z platform.

Thanks for your help in advance,

-Ram.

0 Kudos

1,125 Views
jhnlk
Contributor I

How do I convert this from a KL25 CPU type and pin instructions to use KL26Z CPU and pins?

0 Kudos

1,125 Views
jhnlk
Contributor I

Just had another look, seems actually quite simple.

0 Kudos

1,125 Views
jhnlk
Contributor I

I don't understand the process of this tutorial or its outcome. It could be helpful but it confuses me.

0 Kudos