Use Altium Designer to draw the schematic diagram and use STM32F103 to complete the data reading from the SD card

foreword

Please carefully observe the operation results during the experimental operation, compare with the theoretical results, find problems, and modify the code

Experimental requirements

1. Master the drawing of circuit schematic diagram. Install Altium Designer 18, learn to use Altium Designer to draw a circuit schematic diagram of a stm32 minimum system, and complete the system schematic design of STM32+SD card on this basis. (The drawing of the PCB diagram of the system is not required)
2. Master the principle of the SD card protocol, and use STM32F103 to complete the data reading of the SD card (fat file mode)

1. Draw the schematic diagram of the circuit

Altium Designer integrates board-level and FPGA system design, FPGA and discrete processor-based embedded software development, and PCB layout design, editing and manufacturing in a single design environment. It also integrates modern design data management functions, making Altium Designer a complete solution for electronic product development - a solution that meets both current and future development needs.

Software installation and configuration process

insert image description here
Select Chinese
insert image description here
insert image description here
, modify the installation location, click
insert image description here
next all the way to install successfully
insert image description here
, open the Crack folder, copy the shfolder.dll file to the Altium Designer installation directory,
insert image description here
insert image description here
open the Altium Designer software, select license, select the file and open it.
insert image description here
Successful registration
insert image description here
Click Settings, check Use localized resources , click OK, restart Altium Designer, the localization is successful
insert image description here

(1) Draw the circuit schematic diagram of the stm32 minimum system

As a novice, I can only find a ready-made schematic diagram on the Internet to imitate
the network disk link (Taobao merchant): https://pan.baidu.com/share/init?surl=ipHs1nPdf6Xq3H_OH5j7DA
Extraction code: 7hqu

1. New construction

Click File->New->Project->PCD Project to create a new project

insert image description here

Right-click PCD_Project1.PrjPCB, select Add New to Project->Schematic, create a new schematic diagram

insert image description here

2. Download component library

Link: https://pan.baidu.com/s/1jiJAqjsCjWf41C5edIP7Ww
Extraction code: 1521
insert image description here
insert image description here

3. Draw the schematic diagram

(1) process

Find the stm32f103c8t6 chip in the component library, double-click to open it, place the component in the middle,
insert image description here
click to place the extension pin, left-click on the start and end points to connect, and right-click to release it
(you can use ctrl + c to copy, ctrl + v to paste , press the space to rotate the device every 90°)
insert image description here

insert image description here
Click the Net Label to place the network number, press the tab key to enter the setting window, edit the number name, press Enter to exit the edit box, and then left click to put it down
insert image description here

(2) Results

insert image description here

(2) System schematic design of STM32+SD card

SD card module description
insert image description here
The internal structure
insert image description here
insert image description here
SD card module schematic diagram is as follows
insert image description here

**关于SD卡与stm32模块的连接,第二个任务中有详细介绍,这里不再重复**

1. Drawing steps

Click Libraries in the upper right corner, select the downloaded component library and find the device
AMS1117: stm32f103c8t6 minimum system.SchLib component library
P: Miscellaneous Connectors.IntLib component library search MHDR
C: Miscellaneous Devices LC.IntLib component library search 0805 100uF
insert image description here
insert image description here
insert image description here

2. Schematic display

insert image description here
About the detailed drawing method of AD, you can go to station b to learn, it is very detailed, here is the link
https://www.bilibili.com/video/BV16t411N7RD?from=search&seid=4530935776254031183&spm_id_from=333.337.0.0

2. Read data from SD card

(1) Theoretical knowledge

1. Brief introduction of SD card

SD memory card is a new generation memory device based on semiconductor flash memory. Due to its small size, fast data transmission speed, hot-swappable and other excellent features, it is widely used in portable devices, such as digital cameras, Tablet PCs and multimedia players, etc. There are generally two communication interfaces for the controller to read and write to the SD card, one is the SPI interface, and the other is the SDIO interface.

2. SD card initialization

In SPI operation mode: when the SD card receives the reset command, CS is active level (low level), then the SPI mode is enabled, and 74 clocks must be sent before sending CMD, and 64 clocks are the rising time of the internal power supply. 10 are used for SD card synchronization; the CMD operation can only be started after that, and the CLK clock cannot exceed 400KHz during initialization.

1. Initialize the hardware conditions connected with the SD card (MCU SPI configuration, IO port configuration);
2. Power-on delay (>74 CLK);
3. Reset the card (CMD0), enter the IDLE state;
4. Send CMD8 , check whether it supports the 2.0 protocol;
5. Check the SD card according to different protocols (commands include: CMD55, CMD41, CMD58 and CMD1, etc.
)
; Card initialization, note that the 8 CLKs sent at the end are to provide an extra clock for the SD card to complete certain operations. Through SD card initialization, we can know the type of SD card (V1, V2, V2HC or MMC). After the initialization is completed, we can start to read and write data.

3. SPI protocol

Regarding the SPI protocol, the previous blog has explained in detail, and the blog link is given:
https://blog.csdn.net/m0_48609250/article/details/121558582

4. SD card physical structure

A general SD card includes five parts: storage unit, storage unit interface, power detection, card and interface controller, and interface driver.
insert image description here

insert image description here

存储单元是存储数据部件,存储单元通过存储单元接口与卡控制单元进行数据传输;
电源检测单元保证SD卡工作在合适的电压下,如出现掉电或上状态时,它会使控制单元和存储单元接口复位;
卡及接口控制单元控制SD卡的运行状态,它包括有8个寄存器; 接口驱动器控制SD卡引脚的输入输出。

(2) Experimental process

1. Download the source code

Link: https://pan.baidu.com/s/15Kv471QLosXKGldRckLRpg
Extraction code: 1521

2. Hardware connection

insert image description here
insert image description here

3. Code modification

insert image description here

insert image description here
Here you can also comment out the 272,273 lines of code to achieve the desired effect
and compile without errors
insert image description here

4. Compile and burn

insert image description here

5. SD starts to read in

(1) Initialize the SD card

insert image description here

(2) Send files

insert image description here

(3) The results show

insert image description here

6. Precautions

1、读卡前请格式化,选择FAT模式
2、SD卡与芯片的连接线尽可能选择短的新杜邦线,保证接触良好
3、在SD卡初始化时,等待一段时间,不要心急
4、芯片与SD卡供电电压全都选择5V,3V可能会失败,无法完成初始化
5、USB在插入电脑后不要再动了,有的笔记本电脑串口可能会有接触问题,使用前仔细检查
6、烧录和读卡时芯片boot注意进行置位

3. Summary

Because the drawing of the schematic diagram of the first task is not the focus of this experiment, so I can only find the ready-made schematic diagram on Taobao for imitation drawing. Generally speaking, I have mastered some basic operations of drawing. The SD card data of the second task The reading, the experimental process is actually very simple, but there will always be some hardware problems, such as poor contact of the DuPont line, and the SD card needs to be initialized by pressing. However, the experiment was completed by using a new DuPont line and manual operation. Overall, Said that there is no substantively completed project by myself, and it is re-used on the basis of predecessors. I hope that I can write my own project in the future!

4. References

STM32 uses cube to configure SPI to read and write SD card
SD card to read and write
https://blog.csdn.net/qq_46467126/article/details/122034936

Guess you like

Origin blog.csdn.net/m0_48609250/article/details/122075173