1
\$\begingroup\$

I would like to implement a very low power SD card handling with MSP430 processors. I would like to log measurement data onto SD card without a file system. I want to turn on and off the SD card power to save power. And I would like to reach as fast SD card initialization as I could.

To initialize the SD card I used the @vaxquis suggestion from this issue:

What is the correct command sequence for microSD card initialization in SPI?

It is working great, I can initialize the card, save the data and reload it if necessary.

BUT, after SD card power reset, before the ACMD41 command when I set the chip select signal to LOW, then the SD card will response 0x00 only after approx. ~50-80ms. During that time 0x01 is the response from the SD. So if I keep sending the ACMD41 continuously I got 0x00 response only after 50-80ms. OR, if I set LOW for CS and wait 50-80ms then I immediately got 0x00 response.

After the initialization, everything goes smoothly.

Any suggestion to my problem?

So my init sequence:

  • Enable SD card VCC
  • wait ~1ms
  • start initialization (CS high + send 80 clock)
  • CS LOW
  • CMD0 (arg:0, crc:0x95) + wait R1 response
  • CMD8 (arg:0x000001AA, crc:0x87) + wait R1 + arg echo response
  • CMD55 (arg:0, crc:0x65) + wait response
  • CMD41 (arg:0x40000000, crc:0x77) + wait response
  • repeat ACMD41 (CMD55 + CMD41) until 0x00
  • CS HIGH
  • ... write, read data ...
  • wait ~ 1ms
  • disable SD card VCC
  • sleep ~800ms
  • start again

If the SD card power is not switched, this issue does not appear.

And I am using an 8GB SDHC Ver2.0 card.

\$\endgroup\$
  • \$\begingroup\$ This appears to be a property of that SD card's hardware or firmware. And I doubt that other SD cards are much better. \$\endgroup\$ – CL. Nov 27 '18 at 7:29
  • \$\begingroup\$ Thank you very much for the comment. I was thinking the same just I hoped maybe I missed something or I need a different initialization. If I change the signaling level can I get better performance? And I forgot to mention I do not use pull-up resistors in my circuit because the SPI worked without them. But can they improve the performance? \$\endgroup\$ – D_Dog Nov 27 '18 at 8:08
1
\$\begingroup\$

Reading your question I have got an analogy: stopping vehicle's engine at the red traffic light for a minute or two. You think that: you save a little gas, you save a little on engine wearout, and you believe you are green because do not emit gases within that minute or two.

The issue in this analogy is that all assumptions may be wrong - unless engine is especially designed for regular start-top.

Ordinary engine when started: consumes more gas; emits more pollutiuon; and wears much more.

Now think about your case: how much power SD-card restart consumes versus sleep/inactivity mode? I also advise you looking for special low power card, or the one which is designed for regular power off/power on operations (read: faster startup time and low power consumption during initialization). Not sure such exist, or they may exist for industrial market only (and will cost more than consumer cards).

Update: notice the following in the specification:

6.4.2 Power Down and Power Cycle

When the host shuts down the power, the card VDD shall be lowered to less than 0.5Volt for a minimum period of 1ms. During power down, DAT, CMD, and CLK should be disconnected or driven to logical 0 by the host to avoid a situation that the operating current is drawn through the signal lines.

Thus measuring consumption of SD-card at its power pin may not be enough - current may still flow through signal pins.

In my opinion, for card to consume minimal power in power-on state you must set CLK low (thus use SPI mode 0, or at least ensure it does not toggle) and CS high.

If you still want to stick to power cycle mode when cards may really show long startup times, then there will be no electrical engineering solution, you must perform handling in software. For example, divide data buffer into two parts, and fill one part while starting SD-card and flushing second part. It will assume you will be starting card twice more times, but will ensure no interruption with cards with startup time up to ~250 ms.

And I forgot to mention I do not use pull-up resistors in my circuit because the SPI worked without them. But can they improve the performance?

The will not affect performance, they will affect power consumption. As far as I know resistors may be used for designs critical to metastability, as you drive the only card and perform full initialization from scratch and without MCU output signal floating you do not need pull-ups.

And by the way, forgot to mention: SD-card may have internal pull-ups (most probably weak ones - at least on CS pin), which may be configurable. You may want to ensure disabling internal pull-ups.

\$\endgroup\$
  • \$\begingroup\$ Thank you very much for the detailed comment. As CL. mentioned, yeah this behavior comes probably from property of the SD card and the start-up time cannot be lowered. So you are right, it would not worth it to toggle the power of the SD card. However if I move more bytes to the sd card in one power cycle then I can lower the average consumption. The goal is the 0.5kB/sec datarate. But if I move 25kB in one sec then I'll wait ~50-60sec I could have an average 0.5kB/sec datarate with only one power cycle included. Therefore the overall power consumption will lowered. \$\endgroup\$ – D_Dog Nov 29 '18 at 20:21
  • \$\begingroup\$ The GPIOs and so the SPI interface is driven to low after the powering down the SD card. So they are not floating. \$\endgroup\$ – D_Dog Nov 29 '18 at 20:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.