download
Transplant punctual atom, modify it to Cube library to use
https://download.csdn.net/download/shaynerain/12710346
Introduction
The main protocol of SDCard can be referred to https://shimo.im/docs/pKhdkrHPYyHWRhC3 . The more important thing is that the SD card is slow when writing. If the speed is the same as that of reading, the internal buffer of the SD card will not be released in time, resulting in Cannot write normally. At this time, if the file system is at the end or the beginning of the file, it is very likely that the file system is damaged or the file is damaged;
You can check the reading and writing speed when you buy the card. There is a brief introduction in the agreement I compiled
SPI configuration
Mode 0, SPI speed requires two speeds, high speed and low speed, low speed is used for initialization, and high speed is used for data transmission, which is reflected in the source code. Another thing to note is that if the writing speed is too fast, you can delay processing, or set three SPI speeds to handle initialization, reading, and writing separately.
Brief summary
Pay attention to the speed issue, the unit size does not affect the file system, but the block size must be 512