How to use USB micro port on BluePill

Post here all questions related to STM32 core if you can't find a relevant section!
Post Reply
Jimbo13
Posts: 8
Joined: Sun Feb 16, 2020 6:10 pm
Location: UK

How to use USB micro port on BluePill

Post by Jimbo13 »

Advice please for a BluePill beginner.
I am programming with an ST-LINK.
How do I setup and use the micro USB port on the BluPill board to output data from my programme?
There are 2 optional settings in the Arduino Tools section, USB support and USB speed.
I am not sure how to set these.
Then in the programme how do I start the serial and use it.
I tried without success:
SERIAL_PORT_MONITOR.begin(9600);
SERIAL_PORT_MONITOR.println("ASCII Table");

User avatar
fpiSTM
Posts: 266
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 5
Location: Le Mans
Contact:

Re: How to use USB micro port on BluePill

Post by fpiSTM »

You should have this:
BP.png
BP.png (21.22 KiB) Viewed 107 times
Then simply use "Serial".

Jimbo13
Posts: 8
Joined: Sun Feb 16, 2020 6:10 pm
Location: UK

Re: How to use USB micro port on BluePill

Post by Jimbo13 »

Hi fpiSTM, Still not working, the only difference to what you suggest is that I am not using a bootloader as in your example, I am using STM32CubeProgrammer v2.3.0 with a Chinese ST-LINK.

I am using CoolTerm but cannot see a USB port other than the ST-LINK.

This is my programme:

Code: Select all

void setup() {
    pinMode(PC13, OUTPUT);// Set up the built-in LED pin as an output:
    Serial.begin(9600);
}
void loop() {
    digitalWrite(PC13, !digitalRead(PC13));
    delay(5000);         
    Serial.println("Hello Jim");
}

User avatar
fpiSTM
Posts: 266
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 5
Location: Le Mans
Contact:

Re: How to use USB micro port on BluePill

Post by fpiSTM »

Right, up to you to select the best upload method for you. ;)
BP is known to have an issue with a wrong resistor value for USB detection so it can't enumerate properly.
And there is also some fake BP.

on which os you run? Linux? windows ?
Try to see if there is an unknow device.
Using dmeg on linux or the device manager on Windows.

ag123
Posts: 298
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: How to use USB micro port on BluePill

Post by ag123 »

in linux try something like this
https://github.com/jkulesza/usbreset

in windows, i'm not too sure if 'scan for new hardware' helps, i think it is accessible from device manager
https://answers.microsoft.com/en-us/win ... 2f51929e3c

what is missing is apparently a 'usb reset' (single ended zero) signal is not received by the host or some such problem
so if the host can send a 'usb reset' to all the devices, it may enumerate and show up

Jimbo13
Posts: 8
Joined: Sun Feb 16, 2020 6:10 pm
Location: UK

Re: How to use USB micro port on BluePill

Post by Jimbo13 »

OK I think I have sorted this out.
BP is known to have an issue with a wrong resistor value for USB detection so it can't enumerate properly.
"USB Enumeration is the process of detecting, identifying and loading drivers for a USB device". I replaced resistor R10 on the underside of the BluePill. It was an 006 size resistor marked as 103 i.e 10k. I replaced it with a 008 size 1.5k. I don't think this made any difference, the fault was laziness on my part for not looking carefully at the problem.
To programme the BluePill, Arduino appeared to require a port number for the ST-LINK In "Arduino - Tool - Port" so I selected the only visible COM port, COM3 thinking it was the ST-LINK. The upload process worked and the led blink rate changed as proof. When I opened CoolTerm I could only see COM3 which I assumed was the ST-LINK and that the BluePill was not visible.
When I looked in Win 10 Device Manager I could see the ST-LINK under "Universal Serial Bus Devices" and under "Ports(COM and lpt)" just one "USB serial Device COM 3" with no description to identify it, but by unplugging the ST-LINK the COM3 remained visible so identifying the BluePill as the remaining plugged in COM3 and not the ST-LINK as I had assumed. I now opened CoolTerm and selected COM3 and was able to see the data from my BluePill.
I deduced that the STM32CubeProgrammer finds the ST-LINK ignoring the selection in "Arduino - Tool - Port".
One final thing which I don't yet understand is that whatever baud I select in "Serial.begin(baud);" and whatever receiving board rate I select in the Arduino Monitor or CoolTerm (9600 or 115200 etc) the data from BluePill is still displayed correctly. Probably something on my computer, any suggestions welcome.

ag123
Posts: 298
Joined: Thu Dec 19, 2019 5:30 am
Answers: 1

Re: How to use USB micro port on BluePill

Post by ag123 »

if you are using roger's (maple usb dfu) boot loader. the boot loader first enumerates as
1EAF:0003
this normally works correctly

then the boot loader starts the core. the core then tries to enumerate the same port as
1EAF:0004 - that is for libmaple (maple mini, et.al)

the trouble is while the core is doing that it needs to send a usb reset (single ended zero) to the host and tell the host to enumerate
i'm not sure why this is happening in that it seem this single ended zero is either not transmitted or that the host simply didn't recognise the single ended zero.

i've tested in linux usbreset works, it gets the port to enumerate. this is even true for ST internal on chip DFU boot loader
https://github.com/jkulesza/usbreset
i'm not too sure how to do that in winndows, maybe someone can add to that

User avatar
fpiSTM
Posts: 266
Joined: Wed Dec 11, 2019 7:11 pm
Answers: 5
Location: Le Mans
Contact:

Re: How to use USB micro port on BluePill

Post by fpiSTM »

Baudrate is not relevant usine USB VCP.

Post Reply

Return to “General discussion”