Hi all, I'm new to the forum. I see this thread is a couple years old, but didn't want to open a new one for the same issue. If I should do so, or post elsewhere, please advise and accept my apologies in advance. I have been programming for 40 years but this is a completely new environment, so my experience isn't worth much as far as the new programs and hardware go. But I have been programming in C or C# for a long time so the code, libraries, compiling, and linking is not a mystery.
I am on Windows 10 Home. I use STM32 ST-LINK Utility v4.6.0.0 and the ST-Link V2 (SWD) to download programs. I'm primarily concerned with using the on-board USB as a serial port, not so much with downloading a program with Arduino, although that would be nice (bootloader is another subject entirely). I am using Arduino 1.8.19 and the latest 'STM32 MCU based boards' board files, v2.2.0. There are a bunch of 'STM32...' files in the library manager but I don't see anything specific to USB. I am trying to stay away from the Maple drivers since my understanding is that Roger Clark's code is no longer supported. I am hoping that there is native STM library support for the USB port.
I got a couple of Blue Pills from "aideepen" on Amazon, figuring I had a better chance at the real deal vs ebay (apologies to ebay), since I had heard about 'fakes' being sold. The chip appears to be a genuine STM32F103C8T6, although the mfg. code is "CHN". It has a single spot at the pin 1 corner I would call 'rougher in texture', not a dimple.
Everything that I've tested so far works except USB. I have an ILI9341 TFT display and a WWVB receiver attached, and am using the "WWVB Clock" program from Bruce Hall (search for "Bruce Hall WWVB Clock Project" to find the pfd file for this project). This is a great project to demonstrate the power of this chip and board, and I'm sure there are many others. For this particular project, the PA12 input for WWVB signal was moved to PA10 since PA12 & PA11 are used for the USB port. The program functions as shown in the project file, syncing & displaying the time. At power-up, PA12 is high, but that's almost certainly due to the 152 (1500 ohm) pull-up resistor at R10.
To test the correct USB operation only, I have a simple test program from earlier in this thread (actually it may be from another thread), setting up 'Serial' the same but slightly modified to echo any serial input to the output:
Code: Select all
void setup() {
Serial.begin();
digitalWrite(LED_BUILTIN,0); //on blue pill it is active low, so this is 'ON'
while(! Serial.available() );
digitalWrite(LED_BUILTIN,1);
Serial.println("you are connected");
}
void loop() {
// if a character is available, echo to output
if (Serial.available())
{
Serial.write(Serial.read());
}
}
I compiled and downloaded this program using ST-LINK Utility. When I plug the board into a USB board, I get 'device unrecognized'. The LED stays on, so is not getting past the call to Serial.available(). I don't see how this code knows that 'Serial' is referring to the USB device. This chip supports U(S)ART channels as well as the USB. Is there a specific file I need to include, or library calls to make, to specify that the port I want is the USB port? I'm probably overlooking something really simple.
Thanks for taking a look!