Demo of the usage USBDevice library with Blue Pill STM32F103C8T6 board.

Dependencies:   USBDevice

STM32F103C8T6 USBSerial Demo

This project contains demo of the USB serial usage for a cheap developer board Blue Pill with STM32F103C8T6 mcu.

/media/uploads/vznncv/stm32f103c8_usbserial.jpg

The USB serial port provides a good communication channel between PC and microcontroller. Especially it can be useful for a debug purposes.

Notes

  • by the specifications this board has only 64KB of the flash, but actually it can have 128KB, that will be useful for a debug builds as it requires about 100KB of the flash for this demo.
  • the board can have some problems with an USB because it has wrong value of the pull-up resistor
  • for steady reading of data from a serial port, the project contains python script serial_reader.py (it requires PySerial and six python libraries), that is steady to the board reloading
  • the project depends on the fork of the USBDevice library. This fork contains some fixes and support of the BLUE_PILL_STM32F103C8 target.
  • the mbed-os now contains correct code for a clock initialization of the BLUE_PILL_STM32F103C8 target, so you don't need to adjust the board clocks separately
Committer:
Konstantin Kochin
Date:
Fri Aug 04 18:41:22 2017 +0300
Revision:
0:24604e97c40c
Initial release

The project contains autogenerated makefile for a debug build,
the program itself (main.cpp) and the helper python script
'serial_reader.py' to read a data from a serial port.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Konstantin Kochin 0:24604e97c40c 1 /**
Konstantin Kochin 0:24604e97c40c 2 * The example of the program for STM32F103C8T6 (Blue Pill board).
Konstantin Kochin 0:24604e97c40c 3 *
Konstantin Kochin 0:24604e97c40c 4 * This program demonstrate led and usb serial port usage.
Konstantin Kochin 0:24604e97c40c 5 *
Konstantin Kochin 0:24604e97c40c 6 * @author Kochin Konstantin
Konstantin Kochin 0:24604e97c40c 7 */
Konstantin Kochin 0:24604e97c40c 8 #include "USBSerial.h"
Konstantin Kochin 0:24604e97c40c 9 #include "mbed.h"
Konstantin Kochin 0:24604e97c40c 10 #include "stdio.h"
Konstantin Kochin 0:24604e97c40c 11
Konstantin Kochin 0:24604e97c40c 12 DigitalOut myled(LED1);
Konstantin Kochin 0:24604e97c40c 13 USBSerial usbSerial(0x1f00, 0x2012, 0x0001, false);
Konstantin Kochin 0:24604e97c40c 14
Konstantin Kochin 0:24604e97c40c 15 int main()
Konstantin Kochin 0:24604e97c40c 16 {
Konstantin Kochin 0:24604e97c40c 17 uint32_t counter = 0;
Konstantin Kochin 0:24604e97c40c 18
Konstantin Kochin 0:24604e97c40c 19 while (true) {
Konstantin Kochin 0:24604e97c40c 20 usbSerial.printf("I am a USB serial port. Tick %d.\n", counter);
Konstantin Kochin 0:24604e97c40c 21 counter++;
Konstantin Kochin 0:24604e97c40c 22
Konstantin Kochin 0:24604e97c40c 23 myled = !myled;
Konstantin Kochin 0:24604e97c40c 24
Konstantin Kochin 0:24604e97c40c 25 wait_ms(1000);
Konstantin Kochin 0:24604e97c40c 26 }
Konstantin Kochin 0:24604e97c40c 27 }