SDHC writing block procedure

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

SDHC writing block procedure

Jump to solution
1,164 Views
mariovlw
Contributor I

I am doing a project using the SDHC module in the K64F board, I believe that the initialization process is fine, but now i want to write into the SD card, does anyone has an example for the writing procedure that must be done? 

Now I am trying with the following steps:

  1. Select the card using CMD7 with the RCA given by the CMD3 at the initialization process
  2. Write into the SDHC_DATPORT (the data entered into this register is some random data just to see if my procedure is correct)
  3. Send the CMD24 (Write block) with address 0 
  4. Stop transmission using CMD12 

Note: When I send the CMD24 my card status has the APP_CMD flag set, I wonder if there is a way to reset it or if this does not affect. 

Regards, 

Mario V.

Labels (1)
1 Solution
965 Views
mjbcswitzerland
Specialist V


Hi Mario

To write a single sector one sends CMD24, followed by the 512 bytes of data. CMD12 is used only to terminate a multiple block write (CMD25).

You can download the open source uTasker project from GITHUB for a FRDM-K64F project which allows you to test writing (command "sectw" command) and display sectors (with command "sect" in the debug menu). It also shows how to use the card with utFAT:

http://www.utasker.com/docs/uTasker/uTasker_utFAT.PDF

on a DOS like interface, with FTP and web server or via USB-MSD. You can use it also on memory sticks or in internal Flash or external SPI flash.

You will be able to copy the methods if you need to write the code again yourself and simulate the SDHC and SD card in its simulator with Visual Studio.

To see some parts in action check out the video: https://www.youtube.com/watch?v=VJ7YveF4_8g&index=26&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q

Regards

Mark

For some FRDM-K64F binaries: http://www.utasker.com/kinetis/FRDM-K64F.html

View solution in original post

2 Replies
966 Views
mjbcswitzerland
Specialist V


Hi Mario

To write a single sector one sends CMD24, followed by the 512 bytes of data. CMD12 is used only to terminate a multiple block write (CMD25).

You can download the open source uTasker project from GITHUB for a FRDM-K64F project which allows you to test writing (command "sectw" command) and display sectors (with command "sect" in the debug menu). It also shows how to use the card with utFAT:

http://www.utasker.com/docs/uTasker/uTasker_utFAT.PDF

on a DOS like interface, with FTP and web server or via USB-MSD. You can use it also on memory sticks or in internal Flash or external SPI flash.

You will be able to copy the methods if you need to write the code again yourself and simulate the SDHC and SD card in its simulator with Visual Studio.

To see some parts in action check out the video: https://www.youtube.com/watch?v=VJ7YveF4_8g&index=26&list=PLWKlVb_MqDQFZAulrUywU30v869JBYi9Q

Regards

Mark

For some FRDM-K64F binaries: http://www.utasker.com/kinetis/FRDM-K64F.html

965 Views
mariovlw
Contributor I

Thank you Mark, the information you gave me its really good. I'll take a look more closely and study it. 

0 Kudos