Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] LPC2138 interface to SD-card using Flash File System

Status
Not open for further replies.

salmanliaquat

Full Member level 2
Full Member level 2
Joined
Feb 21, 2011
Messages
128
Helped
38
Reputation
76
Reaction score
38
Trophy points
1,318
Location
Pakistan
Activity points
1,908
Hi,
I am trying to interface LPC2138 with micrSD card(2-GB).
I picked up the demo code for LPC2148 based on Flash File system(since LPC2138 is almost the same as LPC2148 except for usb device peripheral).
On running the code:
I can see the menu on UART(uart is working fine).
But it gives error:
" MMC/SD card init failed.. Insert Card and press key... "

In SPI driver file SPI_LPC214x.c, its using SPI1/SSP port. As for the hardware, connections are perfect and i am able to read and write sectors from sd-card(using another sector read/write code ofcourse).

functions present in SPI_LPC214x.c are:
*----------------------------------------------------------------------------
* SPI Driver Functions
*----------------------------------------------------------------------------
* Required functions for SPI driver module:
* - void spi_init ()
* - void spi_ss (U32 ss)
* - U8 spi_send (U8 outb)
* - void spi_hi_speed (BOOL on)
*---------------------------------------------------------------------------*/

I have even set the heap size to 0x1000 and all other configurations are correct.
Please help if i am missing something.

I am using RL-ARM v4.12 and MDK-ARM v4.21.

Regards,
Salman Liaquat.
 

Can you upload or post a link to the FFS code you are using?

Without seeing the actual code, you may have to preformat the MMC with the appropriate FAT, maybe FAT16.

If the FAT format of the MMC is the wrong type you will get errors such as you have described.

BigDog
 
i have attached the file. It is keil's demo code can be found at
C:\Keil\ARM\Boards\Keil\MCB2140\RL\FlashFS

though i have made little modifications to uart baud setting registers .. since i am using 11.0592MHz crystal.
 

Attachments

  • SD_File.zip
    436.5 KB · Views: 186
Hi all,

My problem is solved now. The problem was in power connection of sd-card. I was giving power to sd card from controller's IO pin. When i gave it power from power source. It worked.

I can't understand why it didn't worked using power from controller's IO pin. What i observed is that the whenever controller tries to communicate to sd-card, the power pin gets a lots of noise in it, so i connected it directly to the power source of 3.3V and that's it.

One more thing is that sector read/write occurred successfully using power from controller's IO pin.

Regards,
Salman
 
Hello!

I can't understand why it didn't worked using power from controller's IO pin.

Check the specs of your IO pins. A regular SD card may need up to 50 mA to work.
(I verified on many SD cards, and I remember having commonly measured power
consumption rates around 40 mA when writing, so 50 mA is a good worst-case estimate.)

The current you cant draw from an IO pin depends on the device. As I use a lot of MSP430
devices, I know that the max power you can draw is around 20 mA. It's OK to blink a LED,
but not to drive an SD card.

Now why you get a lot of noise is simple. When the SD card is idle, it does not draw any
current (or at least something very week, a few microamps). If you switch it on by
sending commands, then it starts drawing power. In this case, since the IO pin cannot
feed enough, then the power voltage drops.

Now I understand your idea: you probably avoid to power the SD card permanently.
In this case, you have to put a FET transistor on the high side (between the board
power and the SD power pin), and command this FET from the IO port you were
using. The idea is fine. However, you should verify how much current your idle
FET will draw vs how much current a permanently powered SD card would draw.
Sometimes, the power saving is so small that it's not worth the added complexity.
And it's also a good source of unforeseen trouble. Think also that you will have
to restart the card initialization every time you switch it on.

Dora.
 
Hi,

Sd-card can take maximum of 60mA of current during communication and the io pin of controller can only provide 4mA at Vout = Vdd, thats why the problem was occuring.
I have it all resolved now.


Can you share your project? I also care about it.
What do you need to know.?
check the pictures in my photo album for hardware that i used and i have already uploaded the code.

Regards,
Salman Liaquat.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top