2018年4月6日 星期五

Black Pill(STM32F103C8T6) to work with Arduino

The Black Pill is a STM32F103C8T6 based controller board with 64K Flash, 20K SRAM, 2x 12-bit ADC, 2x SPI, 2x I2C, 2x USART, 1x USB and 5V-tolerant I/O. It cost 2 to 3 USD from Ebay or Taobao. As its name, Black Pill's PCB color is black and there are different variant called Blue Pill, and Red Pill. From the schematic, you can see the indication LED is connected to PB12. When PB12 is assigned to "0", it will turn-on the LED.


To program the Black Pill, you can use the UART(bootloader) or ST-Link. In addition, you can also use the USB interface, but you need burn the USB bootloader to it in advance. The procedure to work Black Pill with Arduino IDE and USB interface is shown below

1. Burn USB Bootloader

a. Set the BOOT1/BOOT0 as 0/1
b. Prepare a USB-2-UART cable and connect PA9/RX, PA10/TX, +3.3V and ground
d. Start ST flasher loader and upload the firmware
** The setting and connection between Black Pill and USB-2-UART cable need assign properly, otherwise the flash loader program will not go the burn process. The connection and operation menu is displayed.



2. Arduino IDE to support the STM32

a. Get Arduino_STM32 from github and put it over
"C:\Users\<login username>\Documents\Arduino\hardware"
(my example C:\Users\vincentlee\Documents\Arduino\hardware\Arduino_STM32)
b. run "C:\Users\vincentlee\Documents\Arduino\hardware\Arduino_STM32\drivers\win\install_drivers.bat"
to install the driver or you will see error in Arduino upload.
c. Start the Arduino IDE to select and check the Black Pill is supported. The "Get Board Info" menu can show the board information

d. Load the "blink" example, edit the indication LED pin to "PB12" for Black Pill


e. Set the BOOT1/BOOT0=0/0 to boot for flash memory and connect the Black Pill thru USB

f. Compile and upload the Sketch to Black Pill
If the "blink" Sketch is uploaded properly, it will turn-on the LED for 3 sec and turn-off LED for 1 sec continuously.


 If the DFU driver is not installed in procedure 2/b, then the error message
"Couldn't find the DFU device:[1EAF:0003]" is displayed and the upload process failed.

Q&A

1. STM32F103C8T6 part number naming rule
STM = the vendor, STMicroelectronics
32 = 32-bit, i.e. ARM series
F103 = model, “F1” also indicates that this is an ARM Cortex M3
C = 48-pins
8 = flash memory size is 64 KB(B series with 128KB flash and it seems share the same dice as 8 series)
T = package type is LQFP
6 = temperature range -40 to +85 °C

2. BOOT1/BOOT0 selection
From ST's datasheet, it worked as
Boot mode selection pins Boot mode Aliasing Note
BOOT1 BOOT0
x 0 Main Flash memory Main Flash memory is selected as boot space USB bootloader burned to work with Arduino IDE
0 1 System memory System memory is
selected as boot space
USART bootloader
1 1 Embedded SRAM Embedded SRAM is
selected as boot space
SRAM boot for debug

3. The board's COM port is not shown in programming
Sometimes, the used-to-work Black Pill is not function properly to show the COM port anymore. You can try to reset the board or load again the DFU driver again as procedure 2/b

4. reference link
a. Roger Clark's github
    https://github.com/rogerclarkmelbourne
b. stm32duino wiki
    http://wiki.stm32duino.com/index.php?title=Black_Pill
    http://wiki.stm32duino.com/index.php?title=Blue_Pill
    http://wiki.stm32duino.com/index.php?title=Maple_Mini
    http://wiki.stm32duino.com/index.php?title=Red_Pill

1 則留言: