Keil Logo

sd card + spi + Flash-Fs

Next Thread | Thread List | Previous Thread Start a Thread | Settings

Details Message
Read-Only
Author
Salman Liaquat
Posted
24-Sep-2011 19:54 GMT
Toolset
ARM
New! sd card + spi + Flash-Fs

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.

Read-Only
Author
Salman Liaquat
Posted
27-Sep-2011 15:41 GMT
Toolset
ARM
New! RE: sd card + spi + Flash-Fs

Please give me a running code if someone has worked on it.

Read-Only
Author
erik malund
Posted
27-Sep-2011 15:47 GMT
Toolset
ARM
New! RE: sd card + spi + Flash-Fs

Please give me a running code if someone has worked on it.
I'm sure many consultants have, pay one of them

Erik

Read-Only
Author
Salman Liaquat
Posted
28-Sep-2011 17:36 GMT
Toolset
ARM
New! RE: sd card + spi + Flash-Fs

pay one of them
How much..?

Read-Only
Author
Andrew Neil
Posted
28-Sep-2011 23:03 GMT
Toolset
ARM
New! RE: How much..?

You would have to ask for a quote.

Read-Only
Author
wild (1);
Posted
29-Sep-2011 06:13 GMT
Toolset
ARM
New! RE: sd card + spi + Flash-Fs

Things that you have to handle are: clocking, pins, spi

So if you check if clocking is correct, that right pins are initialized and that spi code is working it should all work.

Read-Only
Author
Salman Liaquat
Posted
29-Sep-2011 12:11 GMT
Toolset
ARM
New! RE: sd card + spi + Flash-Fs

Clocking is working and pins are correctly initialized..i have checked it using oscilloscope.
i can see the clock pulse and data on MISO and MOSI pins. SSEL also changes state (i.e goes low while comminication).

Read-Only
Author
Salman Liaquat
Posted
3-Oct-2011 09:30 GMT
Toolset
ARM
New! RE: sd card + spi + Flash-Fs

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

Read-Only
Author
wild (1)
Posted
3-Oct-2011 09:34 GMT
Toolset
ARM
New! RE: sd card + spi + Flash-Fs

Card probably needs consumes more current than IO pin can provide and thing crash.

Read-Only
Author
Andrew Neil
Posted
3-Oct-2011 09:57 GMT
Toolset
None
New! RE: I can't understand why it didn't worked using power from controller's IO pin

I'm very surprised that you got anything at all to "work" (sic) using a controller's IO pin as a power supply!!

=:0

Controller IO pins (unless specifically noted otherwise) are not designed as power supplies!!

Read-Only
Author
Salman Liaquat
Posted
3-Oct-2011 10:35 GMT
Toolset
None
New! RE: I can't understand why it didn't worked using power from controller's IO pin

"Controller IO pins (unless specifically noted otherwise) are not designed as power supplies!!"

If controller's io pin can source current enough to meet the requirement of device, i think it is not poor idea to connect it to power pin of the device(any IC).
I have been using it to drive EEPROM as well successfully.
surprised that you are surprised.......!!!!!!!

Read-Only
Author
Andrew Neil
Posted
3-Oct-2011 11:40 GMT
Toolset
None
New! RE: If controller's io pin can source current enough

Yes - provided that you specifically checked that, and specifically check that it can guarantee that over all operating conditions, and specifically checked that the voltage regulation is acceptable, and...

I think SD-Cards are quite well known to be rather power-hungry - a GPIO is unlikely to be suitable.

Read-Only
Author
Per Westermark
Posted
3-Oct-2011 13:32 GMT
Toolset
None
New! RE: I can't understand why it didn't worked using power from controller's IO pin

Lots of microcontrollers can source lots of current.

But have you noticed something - the data sheet does not claim that the pin feeds will feed the nominal pin voltage at maximum supported current. Check instead what the lowest voltage the pin is guaranteed to supply. Do you think that voltage is ok for your SD card?

For LPC2119/LPC212, for which I happen to have the datasheet, the datasheet says Voh is 0.4V below nominal at 4mA Ioh. What happens if the SD card wants 10mA? It doesn't really matter that the datasheet claims a max Ioh of 45mA short-circuit current. That is at 0V out.

The question here: are you an engineer, who read the datasheets and design within the promises given by the manufacturer, or are you a tinkerer who connects different components and see what happends?

So as an engineer: What is the maximum momentaneous current the SD card requires? How does that current relate to any promises given by the processor manufacturer?

Since you write "surprised that you are surprised.......!!!!!!!" I would like to hear you quote specific promises from the processor manufacturer that shows that your use really is ok. I would be very surprised (!) if you do manage to supply such references.

Read-Only
Author
Salman Liaquat
Posted
3-Oct-2011 14:11 GMT
Toolset
None
New! RE: I can't understand why it didn't worked using power from controller's IO pin

Max current sd-card can use = 60mA
Max current processor can source = 4mA at Voh = Vdd-0.4
Yes, i was wrong there.

But we can use it to power EEPROM since it uses only 3mA max (AT24512).
And i said surprised because i took that as general.
"How did you got anything to work at all"

And i apologize if i got that wrong.

No hard feelings.

Regards,
Salman.

Read-Only
Author
Andrew Neil
Posted
3-Oct-2011 14:45 GMT
Toolset
None
New! RE: i took that as general

"How did you got anything to work at all"

Ah, yes - I did mean, "anything to do with your SD-Crd"

Sure, with a very low-power load your could get away with powering it from a GPIO.

But, even with your EEPROM at 3mA, you're getting close to the stated 4mA point at which Voh droops to Vdd-0.4.

If Vdd is 3V, that's worse than 10% load regulation - so you'd better be very sure that your EEPROM can cope with that...

It's like connecting LEDs direct to port pins with no series resistor; it can be done - but it's really not to be encouraged...

Read-Only
Author
Salman Liaquat
Posted
3-Oct-2011 14:49 GMT
Toolset
None
New! RE: i took that as general

Thanks for the useful information.

Read-Only
Author
Per Westermark
Posted
3-Oct-2011 16:56 GMT
Toolset
None
New! RE: i took that as general

It is common to use a MOS-FET transistor to drive external equipment, when there is a need to be able to cut the supply to reduce the current consumption.

You can find many MOS-FET with very low on resistance. But you have to look carefully about what voltages you need to control them - for some designs, I have to switch the processor pin between actively driven low, and changed to input with a pull-up to 5V, because the used transistor can't be fully controlled with 3.3V. That obviously requires that the processor has 5V-tolerant inputs. In the case of LPC23xx, the input must be tristated or it will clip to 3.3V.

Next Thread | Thread List | Previous Thread Start a Thread | Settings

  Arm logo
Important information

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies.

Change Settings

Privacy Policy Update

Arm’s Privacy Policy has been updated. By continuing to use our site, you consent to Arm’s Privacy Policy. Please review our Privacy Policy to learn more about our collection, use and transfers
of your data.