README.md 5.1 KB
Newer Older
mysterywolf's avatar
mysterywolf 已提交
1 2
# STM32F103C8 Blue Pill Board BSP Introduction

mysterywolf's avatar
mysterywolf 已提交
3
 [[中文]](README_zh.md)
mysterywolf's avatar
mysterywolf 已提交
4

mysterywolf's avatar
mysterywolf 已提交
5
This document records the introduction of the BSP (board support package) provided by the RT-Thread development team for the STM32F103C8 Blue Pill development board.
mysterywolf's avatar
mysterywolf 已提交
6 7 8 9 10 11

The document is covered in four parts:

- Onboard Resources
- Quickly Get Started
- Advanced Features
12
- Read more
mysterywolf's avatar
mysterywolf 已提交
13 14 15 16 17

By reading the ***Quickly Get Started*** section developers can quickly get their hands on this BSP and run RT-Thread on the board. More advanced features will be introduced in the Advanced Features section to help developers take advantage of RT-Thread to drive more on-board resources.



mysterywolf's avatar
mysterywolf 已提交
18 19
## Onboard Resources

20
The Blue Pill is a STM32F103 based development board with Cortex-M3 ARM CPU that runs at 72 MHz, 20 KB of RAM and 64 or 128 KB of flash memory. The microcontroller (MCU) has a USB port, two serial ports, 16 bit PWM pins and 12 bit ADC pins. It runs at 3.3V, but some of its pins are 5V tolerant.
mysterywolf's avatar
mysterywolf 已提交
21

mysterywolf's avatar
mysterywolf 已提交
22
- MCU:STM32F103C8T6 @72MHz, 64KB FLASH , 20KB RAM
mysterywolf's avatar
mysterywolf 已提交
23 24 25 26 27

- Peripherals
  
  - LED:PC13
  
28
- Debug IO interface type: ST-LINK V2 (SWD)
mysterywolf's avatar
mysterywolf 已提交
29 30


mysterywolf's avatar
mysterywolf 已提交
31
![board](figures/Bluepill_pinout.png)
mysterywolf's avatar
mysterywolf 已提交
32 33 34 35 36





mysterywolf's avatar
mysterywolf 已提交
37
## Quickly Get Started
mysterywolf's avatar
mysterywolf 已提交
38 39 40

This BSP provides MDK4, MDK5, and IAR projects for developers and it supports the GCC development environment. Here's an example of the MDK5 development environment, to introduce how to run the system.

41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
### Use ST-LINK Debugger to connect the Blue Pill Board

ST-LINK driver: https://www.st.com/en/development-tools/stsw-link009.html

| ST-LINK Debugger | Blue Pill 4-Pin SWD |
| :--------------: | :-----------------: |
|      SWDIO       |         IO          |
|      SWDCLK      |         CLK         |
|      VCC3.3      |       VCC3.3        |
|       GND        |         GND         |

![connection](figures/connecter1.jpeg)

![connection](figures/connecter2.png)

![connection](figures/connecter3.jpeg)



### Use FTDI adapter(USB to UART) to connect the Blue Pill Board's PA9(Tx) and PA10(Rx) pins

FTDI adapter driver: https://www.ftdichip.com/FTDrivers.htm

You can use other USB to UART adapters to replace FTDI adapter.

| FTDI adapter(USB to UART) |            Blue Pill Board            |
| :-----------------------: | :-----------------------------------: |
|            Tx             |                PA10 Rx                |
|            Rx             |                PA9 Tx                 |
|            GND            |                  GND                  |
|          VCC 3.3          | **Don't need to connect VCC 3.3 pin** |
|           VCC 5           |  **Don't need to connect VCC 5 pin**  |
mysterywolf's avatar
mysterywolf 已提交
73 74 75



mysterywolf's avatar
mysterywolf 已提交
76
![connection](figures/connection.jpg)
mysterywolf's avatar
mysterywolf 已提交
77

78 79 80 81 82 83 84 85 86 87 88 89 90


### Make sure Jumper Position (Both 0 Position)

| BOOTx | High / Low |
| :---: | :--------: |
| BOOT0 |     0      |
| BOOT1 |     0      |

![connection](figures/jumper.jpg)



mysterywolf's avatar
mysterywolf 已提交
91 92
### Compile and Download

93 94 95 96 97 98 99 100 101
- Double-click the `project.uvprojx` file to open the MDK5 project  (**NOT** `template.uvprojx` file)
- Click the “option for target” button
  - Debug: Choose "ST-LINK Debugger" and Click "Setting" button:
    - Port: choose "SW (Serial Wire)"
    - Flash Download: check "Reset and Run"

- Compile and download the program to the board


mysterywolf's avatar
mysterywolf 已提交
102 103 104

### Running Results

mysterywolf's avatar
mysterywolf 已提交
105
After the program is successfully downloaded, the system runs automatically. Observe the running results of the LED on the development board, and you will see the LED is flashing periodically.
mysterywolf's avatar
mysterywolf 已提交
106

107
The USB virtual COM port connects to **USART1 (PA9-Tx, PA10-Rx) by default**, and when the corresponding serial port (**115200**-8-1-N) is opened in the terminal tool, the output information of RT-Thread can be seen when the device is reset:
mysterywolf's avatar
mysterywolf 已提交
108 109 110 111 112 113 114 115 116

```shell
 \ | /
- RT -     Thread Operating System
 / | \     4.0.0 build Dec 21 2018
 2006 - 2018 Copyright by rt-thread team
msh >
```

117 118
- If you have no terminal tool software available, you can download *Putty*: https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html

mysterywolf's avatar
mysterywolf 已提交
119 120 121 122


## **Advanced Features**

mysterywolf's avatar
mysterywolf 已提交
123
This BSP only enables GPIO and USART1 by default. If you need more advanced features such as SPI, ADC, or to add software packages, you need to configure the BSP with RT-Thread [ENV tools](https://www.rt-thread.io/download.html?download=Env), as follows:
mysterywolf's avatar
mysterywolf 已提交
124

mysterywolf's avatar
mysterywolf 已提交
125
1. Open the ENV tool under the specific BSP folder, eg: *bsp/stm32/stm32f103-blue-pill* ;
mysterywolf's avatar
mysterywolf 已提交
126 127 128 129 130 131 132 133
2. Enter `menuconfig` command to configure the project, then save and exit;
3. Enter `pkgs --update` command to update the package;
4. Enter `scons --target=mdk4/mdk5/iar` command to regenerate the project.

Learn how to use RT-Thread ENV, click [Here](https://github.com/RT-Thread/rtthread-manual-doc/blob/master/env/env.md).



134
## Read more
mysterywolf's avatar
mysterywolf 已提交
135

mysterywolf's avatar
mysterywolf 已提交
136
- [[Schematic]](https://stm32duinoforum.com/forum/images/c/c1/wiki_subdomain/Vcc-gnd.com-STM32F103C8-schematic.pdf)
mysterywolf's avatar
mysterywolf 已提交
137 138 139 140 141 142 143 144 145
- [[STM32 Blue Pill vs Black Pill Microcontroller Boards]](https://www.youtube.com/watch?v=QCdnO43RBK4&t=875s)
- [[STM32F103C8 datasheet]]( https://www.st.com/resource/en/datasheet/stm32f103c8.pdf)
- [[STM32F103C8 More Information]](https://www.st.com/en/microcontrollers-microprocessors/stm32f103c8.html#overview)




## Maintained By

146
Meco Man @ RT-Thread Community
mysterywolf's avatar
mysterywolf 已提交
147 148 149 150

jiantingman@foxmail.com 

https://github.com/mysterywolf