![]() You need to read parts of it to survive (at least Chapter 7: SPI Mode, the rest is not needed much for SPI because SPI only supports basic commands and functionality) and I will refer to it often. SD Specification Part 1 Physical Layer (Simplified Specification), current version 8.00. Most important, the specification itself:. ![]() Specification, Tutorials, Application Notes I didn't test them, but you might want to look at them for important data. There seem to be power-failure tolerant SD cards / industrial SD cards that claim to be power-failure resilient according to this thread. How do I protect SD card against unexpected power failures? This might also happen when you think you don't write data since the SD card controller might resort data internally: If the card "falls asleep", it won't wake up again unless you cut the power to reset it or you physically re-insert it: SD Card Reset Issueīe aware that data loss may occur when the power fails during writing or erasing cycles. to cut off its supply and enable it again. It might be beneficial to be able to power-cycle the SD card, e.g. EDIT: I used ceramic capacitors (3x 22 ♟, 1x 10 ♟, 1x 1 ♟, 1x 100 nF) close to the SD card and separated from the main supply rail by a 1 Ω resistor and measured a transient voltage drop from 3.30 V to 3.22 V for about 100 µs when inserting the card, which is fine. The SD card will draw significant currents when plugging in, which might cause a brown-out for both the SD card and other components. Use large buffer capacitors placed right at the SD card (e.g. (I solved it by sending the data to a "dummy" slave with the CS pin of this dummy/virtual slave unconnected - that way the microcontroller can deal with the CS lines by itself.)Īlso, start without using any other slaves until the initialization sequence works well, then you may re-enable the other slaves (after the initialization or even during initialization). one byte 0xFF), then you can communicate with other slaves. So: CS low, exchange data with SD card, CS high, send dummy data (e.g. Otherwise, the SD card will keep the DO/MISO ((master in slave out)) output active and cause two slaves to drive/short-circuit the MISO line! If you share the SPI bus with other slaves, always send another "dummy" byte (or more) with the CS line inactive (high) after each communication to the SD card before accessing other slaves. only using different chip select (CS) lines), I would not recommend it - it saves you some trouble to use separate SPI buses. All the libraries I've seen are not real-time capable and can take quite some time to execute, at least from my understanding, so here we are.)Īlthough it is possible to share the SPI bus with SD card and other slaves (e.g. (For example, I had a real-time microcontroller system that only has small periodic time slots in which I can perform SD card logging tasks and start/evaluate SPI sequences. Instead, you can use tools like HxD or the dd command on Linux ( Windows versions are available as well) to read/copy the raw data. However, the disadvantage is that you can't simply read the data with a file explorer. If you can't use the libraries for some reasons, you can also initialize the SD card on your own (which is what I describe here) and write to the SD card blocks/sectors directly without a (proper) file system or with your own one.
0 Comments
Leave a Reply. |