==== vcc-gnd STM32F103C8T6 ====
{{:boards:vcc-gnd-st-link-ftdi-bitscope.jpg?200|STLink FTDI BITSCOPE}}
\\ \\
{{:boards:vcc-gnd.jpg?100|STLink}}
\\ \\
{{:boards:vgstm32flash.jpg?100|STM32Flash}}
These are cheap development Arm Cortex-M3 boards with 64KB flash and 20KB ram.
The firmware that ships on these devices blinks the LED on PC13 and sends a time
string on the UART at 9600 baud.
These boards can be programmed using SWD or with the STM serial boot loader in ROM. Both types of programmer are inexpensive but the latter more versatile if somewhat slower in operation.
=== Pinout ===
SPI2 NSS PB12 MICRO USB GND
SPI2 SCK PB13 GND
SPI2 MISO PB14 3V3
SPI2 MOSO PB15 RESET GND GND RESET
PA8 BUTTON *BOOT1 *BOOT0 PB11 ICC2 SDA
USART1 TX PA9 3V3 3V3 PB10 I2C2 SCL
USART1 RX PA10 PB1
CAN1_RX USBDM USART1 CTS PA11 PB0
CAN1_TX USBDP USART1 RTS PA12 PA7 SPI1 MOSI
PA15 PA6 SPI1 MISO
PB3 STM32F103C8T6 PA5 SPI1 SCK
PB4 PA4 SPI1 NSS
PB5 PA3 USART2 RX
I2C1 SCK PB6 PA2 USART2 TX
I2C1 SDA PB7 8MHz PA1 USART2 RTS
CAN1_RX PB8 32.768K PA0 USART2 CTS
CAN1_TX PB9 PC15
5V PC13 POWER PC14
GND LED LED PC13
3V3 SWD VBAT
3V3 DIO DCLK GND
PA13 PA14
*100K IN SERIES
NB not all and only default alternate functions shown
===Clocks===
HSE 8000000 Y2 8 MHz
HSI 8000000
LSE 32768 Y3 32.768K
LSI 40000
=== Power ===
Power is supplied on the USB socket which feeds a 3V3 LDO regulator.
It is possible to power the device with 3V3 on the 3V3 pin or 5V on the 5V pin (to feed the LDO) if USB is disconnected.
=== LED demo ===
This demo depends on [[:tools:libopencm3|OpenCM3]] and this must be installed first.
== STLink ==
Install the [[:tools:stlink|STLink]] programmer to program using a SWD interface found, for example, on the [[:boards:stm32f4|STM32 F4 discovery]] (see top picture).
Fetch blinky, install and run.
hg clone http://hg.kewl.org/pub/miniblink-vcc-gnd
cd miniblink-vcc-gnd
make
make st-flash
FLASH miniblink.bin
INFO src/stlink-common.c: Loading device parameters....
INFO src/stlink-common.c: Device connected is: F1 Medium-density device, id 0x20036410
INFO src/stlink-common.c: SRAM size: 0x5000 bytes (20 KiB), Flash: 0x10000 bytes (64 KiB) in pages of 1024 bytes
INFO src/stlink-common.c: Attempting to write 664 (0x298) bytes to stm32 address: 134217728 (0x8000000)
Flash page at addr: 0x08000000 erased
INFO src/stlink-common.c: Finished erasing 1 pages of 1024 (0x400) bytes
INFO src/stlink-common.c: Starting Flash write for VL/F0/F3 core id
INFO src/stlink-common.c: Successfully loaded flash loader in sram
0/0 pages written
INFO src/stlink-common.c: Starting verification of write complete
INFO src/stlink-common.c: Flash written and verified! jolly good!
== STM32Flash ==
It is also possible to use [[:tools:stm32flash|STM32Flash]], however, this cannot function with USB connected since if the chip detects BOOT0 raised along with a USB cable on reset, it enters DFU mode.
To use [[:tools:stm32flash|STM32Flash]], disconnect USB and power with 3V3 on the 3V3 pin using a 3V3 USB serial adapter. You must cross over serial Rx and Tx and place the jumpers with BOOT1 at 0 and BOOT0 at 1 (see bottom picture).
Probe the chip with [[:tools:stm32flash|STM32Flash]]. This may take a few attempts to synchronise.
stm32flash /dev/ttyUSB0
stm32flash 0.4
http://stm32flash.googlecode.com/
Interface serial_posix: 57600 8E1
Version : 0x22
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0410 (Medium-density)
- RAM : 20KiB (512b reserved by bootloader)
- Flash : 128KiB (sector size: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
The flash size reported by [[:tools:stm32flash|STM32Flash]] would appear to be hard-coded and in this case wrong, ignore that.
Now fetch blinky, install and run.
hg clone http://hg.kewl.org/pub/miniblink-vcc-gnd
cd miniblink-vcc-gnd
make
make stm32flash
FLASH miniblink.bin
stm32flash -w miniblink.bin -b 57600 -v -g 0 /dev/ttyUSB0
stm32flash 0.4
http://stm32flash.googlecode.com/
Using Parser : Raw BINARY
Interface serial_posix: 57600 8E1
Version : 0x22
Option 1 : 0x00
Option 2 : 0x00
Device ID : 0x0410 (Medium-density)
- RAM : 20KiB (512b reserved by bootloader)
- Flash : 128KiB (sector size: 4x1024)
- Option RAM : 16b
- System RAM : 2KiB
Write to memory
Erasing memory
Wrote and verified address 0x080004b0 (100.00%) Done.
Starting execution at address 0x08000000... done.
To reprogram the device, press reset on the board. Remember not to connect USB simultaneously.
=== Resources ===
[[http://item.taobao.com/item.htm?spm=a1z10.1-c.w4004-6273769137.4.zCAqSz&id=22097803050|Product page]]
{{downloads:The-Generic-STM32F103-Pinout-Diagram.pdf|Pinout}}
{{downloads:Vcc-gnd.com-STM32F103C8-schematic.pdf|Schematic}}
[[https://www.st.com/resource/en/datasheet/stm32f103cb.pdf|MCU Data-sheet]]
[[https://www.st.com/resource/en/reference_manual/rm0008-stm32f101xx-stm32f102xx-stm32f103xx-stm32f105xx-and-stm32f107xx-advanced-armbased-32bit-mcus-stmicroelectronics.pdf|MCU reference manual]]