SD CARD + TWRLCD + TWRMCF52259

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

SD CARD + TWRLCD + TWRMCF52259

Jump to solution
2,859 Views
M_ttferrari
Contributor III

HI, I'm trying to find the way to read/write an SD card on TWRLCD handled by TWRMCF52259. I'm following the sdcard example of MQX 3.6.1 (msf/examples/sdcard), the example work fine until line where it need be open with fopen("sdcard:",0) -> this function return a NULL handle, so the sd_task, then, is blocked.

 

I don't know where continue finding out... Any ideas about what it is happening??

 

Thanks 

0 Kudos
Reply
1 Solution
1,914 Views
M_ttferrari
Contributor III

The problem was solved setting as input with internal pullups the PORTE [4:7] of MCF51JM on TWRLCD.

 

Now the example work fine.

 

Thank you for your aswer PetrM...

View solution in original post

0 Kudos
Reply
3 Replies
1,914 Views
PetrM
Senior Contributor I

Hello,

 

this is standard behaviour when SD card cannot be initialized (mostly due to SPI/eSDHC communication problems).

I'm suggesting to run it without TWRLCD. If that works, the problem is in SPI connections.

On twrmcf52259, the QSPI is connected to both SPI0 and SPI1 pins on elevator port B. Please check all those connections if they interfere with something on LCD board (check also LCD jumpers/switches).

 

PetrM

 

0 Kudos
Reply
1,914 Views
M_ttferrari
Contributor III

Hi PetrM

 

If I run it without TWRLCD I won't have a SD card Slot. 

 

LDC switch configurations are:

 

SW1/JP1=OFF, SW1/JP2=ON, SW1/JP3=ON, SW1/JP4=ON, SW1/JP5=ON, SW1/JP6=OFF, SW1/JP7=ON, SW1/JP8=OFF

 

I'm suspecting that some defines like BSP_SDCARD_GPIO_CS, BSP_SDCARD_GPIO_DETECT, BSP_SDCARD_GPIO_PROTECT and BSP_SDCARD_SPI_CHANNEL all of these define are in twrmcf52259.h, but I don't know where the project is doing refece to this file because when I search "twrmcf52259.h" inside the project I don't have any results.

 

By other hand, demo.c has some conditional compiles, one of them is #if defined BSP_SDCARD_GPIO_CS at least that I define this macro in demo.c, this conditional compilation line doesn't compile even if I include twrmcf52259.h a quite rare situation, doesn't it?

 

So, I don't know if I need BSP_SDCARD_GPIO_SC or not and, I don't know too, what is it happening with QSPI...

 

Matt

0 Kudos
Reply
1,915 Views
M_ttferrari
Contributor III

The problem was solved setting as input with internal pullups the PORTE [4:7] of MCF51JM on TWRLCD.

 

Now the example work fine.

 

Thank you for your aswer PetrM...

0 Kudos
Reply