mini STM32F103C8T6 CH340 Serial pins

All about boards manufactured by ST
Post Reply
shuptuu
Posts: 4
Joined: Sat Jun 07, 2025 9:37 pm

mini STM32F103C8T6 CH340 Serial pins

Post by shuptuu »

Hi,
I'm new to STM32 mcus. And to start with I got this mini STM32F103C8T6 CH340 from aliexpress:
(https://fr.aliexpress.com/item/1005006910706030.html)
There is a ch340 chip on it so you can directly flash the board by pluging the board on a usb port. Works great (see below settings in Arduino IDE)
But looks like this board doesn't respect default pins for the Serial (over the usb port).
If I just set Serial.begin(115200) in the setup, and then add some Serial.println, I can't see anything in my serial monitor.
According this board schema, the tx pin is PA9 and the rx pin is PA10
So what do I have to do to get Serial to work properly?

For your information, Arduino IDE settings for this board:
-additionnal board url: -https://github.com/stm32duino/BoardMana ... index.json
-Board selection: Generic STM32F1 series
-Board part number: Generic F103C8Tx
-Upload Method: STM32CubeProgrammer (Serial) => STM32CubeProgrammer must be installed first
Then BT0+RST buttons to set the board in upload mode. Upload in Arduino IDE and that's it.
GonzoG
Posts: 502
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: mini STM32F103C8T6 CH340 Serial pins

Post by GonzoG »

What are your settings for UART and USB support in Arduino IDE ??
shuptuu
Posts: 4
Joined: Sat Jun 07, 2025 9:37 pm

Re: mini STM32F103C8T6 CH340 Serial pins

Post by shuptuu »

Thanks for your answer, good point!
So for "USB support (if available)", it's on None
for "U(s)ART support", it's on "Enable (generic 'Serial')"
and for "USB speed (if available)", it's on "Low/Full speed"

I just made a try selecting "CDC (generic 'Serial' superseed U(s)UART)" for "USB support" but it doesn't change anything.

On the page product on Aliexpress, in the presentation, there is a paragraph I don't fully understand but which could give a clue:
"About TYPE-C port function selection
The core board pursues a small size for a single TYPE-C port design, and the USB function and serial port function are mutually Exclusive design, when welding U2(CH340N) without welding R4 and R5, port C is used as a serial communication function.
When U2(CH340N) is not welded to R5 and R5, port C is used as a USB communication function"


But i won't weld or unweld resistors!!
GonzoG
Posts: 502
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: mini STM32F103C8T6 CH340 Serial pins

Post by GonzoG »

STM32F103 has a USB interface built-in. Those are PA11 and PA12 pins. But it does not have USB bootloader (called DFU by STM) so you cannot flash firmware using USB without software bootloader (like HID bootloader)

It looks like those jumpers (not resistors) are under CH340 and by default are not shorted, as it has CH340 connected to USB, not the STM chip.
With USB support disabled you should be able to see any serial output using "Serial" object.
If you remove CH340 chip you should have access to those jumpers and then they need to be shorted (soldered) to connect USB socket to STM chip usb pins.

But you selected wrong board. "Generic" boards are just that - a generic setup, meant to be used as a base for making setups dedicated for boards. Usually they have different default pin assigned (I think first on the list) and always use built-in oscillators (not that accurate) for clock setup.

Your board has 8M external oscillator and LED on PC13, so you should use C8 BluePill.
ag123
Posts: 1906
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: mini STM32F103C8T6 CH340 Serial pins

Post by ag123 »

To program stm32f103c8t6 blue pill via uart you need to set boot0
and you need stm32cubeprogrammer (or some such programming util)
https://www.st.com/en/development-tools ... eprog.html
^^ this is from ST (you can consider that an official programming tool)

and a google search leads to various guides / tutorials
https://www.instructables.com/Getting-S ... rduino-ID/
viewtopic.php?t=1642
https://microcontrollerslab.com/stm32-b ... 32cubeide/

----
and if you want to use a virtual com port with your blue pill sketch (app / firmware), select
tools > USB support > CDC generic Serial (supercede U(S)ART)

and in your sketch you would be able to use the serial port by connecting that using a usb (phone) cable (ch340 or such serial dongle required)
after your program your sketch into the board.

Code: Select all

void setup() {
	Serial.begin();
	pinMode(LED_BUILTIN, OUTPUT);
}

void loop() 
{
	digitalWrite(LED_BUILTIN, ! digitalRead(LED_BUILTIN)); // blink the led
	Serial.println("hello world");
	delay(1000);
}
---
and note that the wiki is here
https://github.com/stm32duino/Arduino_Core_STM32/wiki
and getting started guide (in the wiki) is here
https://github.com/stm32duino/Arduino_C ... ng-Started
fpiSTM
Posts: 1951
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 109
Location: Le Mans
Contact:

Re: mini STM32F103C8T6 CH340 Serial pins

Post by fpiSTM »

If you select the generic target, the default Serial pins are not PA9/PA10 but PA2/PA3:
https://github.com/stm32duino/Arduino_C ... #L140-L145

You can change it at sketch level using the setRx/setTx API: https://github.com/stm32duino/Arduino_C ... tance-pins

or use the BluePill target then Serial will be by default on PA9/PA10.
GonzoG
Posts: 502
Joined: Wed Jan 15, 2020 11:30 am
Answers: 36
Location: Prudnik, Poland

Re: mini STM32F103C8T6 CH340 Serial pins

Post by GonzoG »

ag123 wrote: Tue Jun 10, 2025 1:52 am To program stm32f103c8t6 blue pill via uart you need to set boot0
and you need stm32cubeprogrammer (or some such programming util)
https://www.st.com/en/development-tools ... eprog.html
^^ this is from ST (you can consider that an official programming tool)
Isn't that exactly what he wrote ??
shuptuu wrote: Mon Jun 09, 2025 11:28 am -Upload Method: STM32CubeProgrammer (Serial) => STM32CubeProgrammer must be installed first
Then BT0+RST buttons to set the board in upload mode. Upload in Arduino IDE and that's it.



ag123 wrote: Tue Jun 10, 2025 1:52 am and if you want to use a virtual com port with your blue pill sketch (app / firmware), select
tools > USB support > CDC generic Serial (supercede U(S)ART)

and in your sketch you would be able to use the serial port by connecting that using a usb (phone) cable (ch340 or such serial dongle required)
after your program your sketch into the board.

WRONG !!!!
1. He cannot use USB features of MCU. USB is not connected.
2. If you setup USB CDC, then you don't need and cannot use any USB-TTL adapter.
ag123
Posts: 1906
Joined: Thu Dec 19, 2019 5:30 am
Answers: 30

Re: mini STM32F103C8T6 CH340 Serial pins

Post by ag123 »

@fpiSTM is correct

it is a bit surprising that they put a usb-uart (ch340n) at pa9 / pa10 which is in turn connected to usb, as normally stm32f103 has its own usb.
stm32f103mini
stm32f103mini
stm32f103mini_sch.jpg (95.66 KiB) Viewed 713 times
in this case, you'd need to use the normal uart option for Serial in your sketch

and it use buttons instead of jumpers, the button dance normally is
- press both reset and boot0
- hold boot0 , release reset
- release boot0 2 secs later
to go into the bootloader (program / flash) mode

Then use stm32cubeprogrammer to program it over serial (uart) interface.
this is for programming
shuptuu
Posts: 4
Joined: Sat Jun 07, 2025 9:37 pm

Re: mini STM32F103C8T6 CH340 Serial pins

Post by shuptuu »

Hi,
Thanks everybody for your contributions, I really appreciate.
I got it!!
Thanks to @fpiSTM 's link on how to change Serial pins at sketch level.
I added:

Code: Select all

  Serial.setRx(PA10);
  Serial.setTx(PA9);
Before the Serial.begin, and now I can see the messages in the serial monitor.
By the way I made a test also selecting "BluePill F103C8" as Board part number: it doesn't work, I can't upload the sketch.
So back to "Generic F103C8Tx", It works.
shuptuu
Posts: 4
Joined: Sat Jun 07, 2025 9:37 pm

Re: mini STM32F103C8T6 CH340 Serial pins

Post by shuptuu »

Sorry, I'm new to this forum. Is there something to do to mark this topic as "Sorted"?
Post Reply

Return to “STM boards (Discovery, Eval, Nucleo, ...)”