SDHC driver and Flash program routines for Kinetis K60N512

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

SDHC driver and Flash program routines for Kinetis K60N512

4,646 Views
gustavod
Contributor III

Hi Everyone,

 

I would like to know if there is any demo code for SDHC and/or flash programming for the TWR-K60N512-KIT.

I usually use SD card with SPI port. However, as far I know it is not possible to use SPI with the SD card in this kit due to the pin connections.

 

I'm trying to develop a complete demo for this kit features. The flash programming routines will allow us to save the calibration info to the LCD touch screen (TWR-LCD).

 

PS.: I know that there is such routines in MQX RTOS, but i would like to know if there is routines without RTOS.

 

Thanks in advance,

Gustavo

 

0 Kudos
14 Replies

1,386 Views
mjbcswitzerland
Specialist V

Gustavo

 

I have used the SD cards in SPI mode on the K60 tower kit board and also on the LCD extension (uSD) board. It is however correct that the connects don't support SPI without a modification. In both cases the MOSI and MISO lines need to be swapped (I did this at the SD card socket of the local card and at the bus connector for the remote one). Details here: http://www.towergeeks.org/forum/topics/sd-card-on-the-kinetis-tower As mentioned there, I do expect that this was a pin out error when the Kinetis was designed (and not a board error) since usually the chips are layed out so that both SPI and SDHC modes can be used with the same wiring. This is something that can no longer be changed so it does make sense in concentrating on the SDHC mode so that the other is not actually of interest. At the time of writing I can't add any more about the SDHC mode since that is also one of the next jobs on my own list... (but, if there is code in the MQX examples I would think that it can be used directly since it is unlikely to be RTOS specific).

 

Regards

 

Mark

 

0 Kudos

1,386 Views
gustavod
Contributor III

Hi Mark,

I figured out the problem with the SD card + TWR-LCD. The Write protect pin of the SD card is connected to the LCD reset pin. Therefore, in order to use LCD and SD card together it is necessary to turn on the SD card write protect switch. By the way, i finished the SDHC driver and SD card is working just fine.

 

Regards,

Gustavo

0 Kudos

1,386 Views
mjbcswitzerland
Specialist V

Hi Gustavo

 

I just checked the TFT and SD card operation according to the M52259 Tower demo here: http://www.youtube.com/watch?v=AdtRyQ-2IrE , using the SD card slot on the LCD board.

 

Checking the circuit I didn't find any connection between the write protect input on the local SD card and the TFT's reset line. On my board the reset line of the TFT is connected (via a NAND gate) to the reset input of the the processor.

 

Are you sure that that was your problem? Do you have a different generation of the tower kit which is different?

 

Regards

 

Mark

 

 

0 Kudos

1,386 Views
gustavod
Contributor III

Hi mark,

 

I´m sure about this, cause i checked in the schematics too (Rev. C). But this problem is on the kinetis TWR-K60N512-KIT, not in the Coldfire V2 tower kit.

 

Regards,

Gustavo

0 Kudos

1,386 Views
mjbcswitzerland
Specialist V

Hi Gustavo

 

1) I have the K60 board with Schematics Rev. C. What I meant was that I am running the same software as shown in the video with the M52259 on the K60 (the project will run on both V2 and Kinetis and I checked that the behaviour was identical with both processors; I just don't have a Kinetis video that i could point to).

 

2) On the TWR-K60N512 board the SD card's write protect pin is connected to PE27, which is connected to A11 of the elevator's backplane. On the backplane this is named GPIO7/OPEN and connected to J8-11 on the TFT board's connector.

On the TFT board (TWR-LCD Rev-B.) this is connected to J4-11 (EGPIO7). This is then connected to the joy-stick (SWN).

 

I am trying to work out how you have a connection to the TFT's reset line?? Maybe your TWR-LCD board is different?

 

Regards


Mark

 

0 Kudos

1,386 Views
gustavod
Contributor III

Hi Mark,

 

I attached a sequence of figures in order to explain how the LCD reset line is connected to the SD card write proctecion pin.

 

Regards,

Gustavo

0 Kudos

1,386 Views
mjbcswitzerland
Specialist V

Hi Gustavo

 

Here are mine. They look different. That seems to mean that there are more than one rev. C schema...

 

Your reset out line is attached to PE27 - and mine not...

 

By the way. Could you get the internal DMA operation to work (ADMA)? I am getting data from the chip (visible with logic analyser) but the ADMA2 is giving an error that its buffer descriptor is invalid. Its buffer descriptor is very simple and I don't see why it reports that the valid bit is not set (even if I fill the buffer descriptor with 0xffffffff 0xffffffff it reports the same error, even though no bit is a '0'...(?))

 

Regards

 

Mark

 

0 Kudos

1,386 Views
gustavod
Contributor III

Hi Mark,

 

I was wrong about the revision of my tower kit. Mine is rev. D and, in D revision the write protect pin is conected to the LCD reset line.

 

Concerning your question, i've never used ADMA, so i can not help you. Sorry !!!

 

Regards,

Gustavo

 

0 Kudos

1,386 Views
sharp4016
Contributor I
Hi,my mistake,,it's mbr
0 Kudos

1,386 Views
mjbcswitzerland
Specialist V

Hi Gustavo

 

Thanks for the clarification. It is useful to know about this change, since it obviously causes undesirable interaction between the SD card and the TFT. I would prefer the Rev. C circuit compared to the Rev. D one so am wondering what the best recommendation is - is is possible to modify the board back to the Rev. C connection?

 

Concerning ADMA - I didn't make any progress on this and also there doesn't seem to be any code reference available for the device. The operation seems quite straight-forward but there are a few points in the documentation that are a bit unclear (like whether the 64 bit information in the buffer descriptors are in little-endian or big-endian format). After trying all permutations that I could work out and not getting any different reaction in any cases I resorted to the simple FIFO solution. In fact I didn't actually see any real advantage of the ADMA operation for the file system interface so I think that the ADMA can in fact be ignored (maybe when doing large buffer transfers with something like a WIFI card it could be interesting but by then there may be a reference - assuming that it does work...).

 

This means that SPI and SDHC file system operation both work correctly - the SDHC is a bit faster of course, which is noticable when displaying images from the SD card on to the TFT. I have a unit on line at http://demo.uTasker.com which also displays the TFT image presently being displayed via Web server (on the "TFT Demo Page") - new images can also be uploaded from the same page and are displayed in the TFT.

 

My next job is to get the Ethernet IEEE 1588 part operating and extending the IPv6 features of the Dual stack...It would be nice to be able to release the next version to coincide with World IPv6 day (8th June) when Facebook, Google, Yahoo etc. will be activating their Dual-Stack IPv6 services.

 

Regards

 

Mark

 

0 Kudos

1,386 Views
gustavod
Contributor III

Hi Mark,

 

I implemented a bare metal SDHC driver through the MQX driver. At this moment i have just tested read and list functions (cause i did not implement some sdhc miscellaneous functions needed to write functions, i.e., "Get erase block size in unit of sector").

 

If you would like to try it i can attach the project in a next message. However, i'm facing a problem with the SD card and TWR-LCD board. The TWR-LCD is working ok, but if i put the SD card into the socket of the TWR-K60N512 the LCD stop working. ave you faced similar problem?

 

Thanks in advance,

Gustavo

0 Kudos

1,386 Views
sharp4016
Contributor I

Hello,gustavod

      Could you please open the source code of sdhc module to me, if available.I'm just working on it, my mail addr: tandanttdd@163.com.

    Thanks.

0 Kudos

1,386 Views
gustavod
Contributor III
Hi Sharp, The source code is completely open source and available in our RTOS project. You can download the demo here: http://brtos.googlecode.com/files/BRTOS%201.66%20Kinetis%20-%20SD%20card%20-%20BMP%2024%20bit.rar Best regards, Gustavo
0 Kudos

1,386 Views
sharp4016
Contributor I

Hi, when i was lookin' at the pin configuration,i thought that ESDHC.D3 should be pull down(acts as a card detection pin).While example codes in mqx does not look like that .

Another problem bothering me is that, my sd memory card support sdhc(marked as 32GB,made in japan,you know, it can't be large as 32BG,actually, about 29 GB,calculated by 1024,or 31GB, by 1000), but  when i gain access to index i block,the CMD17 parameter-- block index, should  be shifted by 9 bit, as below:

   i<<9; not i

Is there a switch between standard sd memory card and high capacity memory card?

Best Regards

sharp4016

email: tandanttdd@163.com

Mainland China

0 Kudos