Would you like to know how your BluePill can be programmed via UART in the Arduino IDE? Read the rest of the article to find out.
Introduction
In the previous blog post, your Bluepill was programmed using ST-Link hardware. However, some of you may not have that hardware available. With this, you can program your Bluepill (or other STM32 microcontrollers) by only using a USB-to-UART converter module.
Bluepill Operating Modes
Before diving into programming your BluePill, it’s better to know its operating modes. This STM32 ARM microcontroller can be in Bootloader or Normal Operating Mode. Being in Bootloader mode means this device is ready to be programmed through USB or UART, flashing firmware into the program memory area, without needing an ST-Link hardware module.Â
Note that if you have an ST-Link utility, you can directly program the Bluepill via the SWD lines as was done in Bluepill Arduino IDE ST-Link Programming.
Before you begin, you’ll have to adjust some jumpers in order to enter UART (System) Bootloader mode. Put the Boot0Â jumper to position 1 while putting Boot1 to 0 (as seen below).
Once finished, you can return the jumper back in Normal Operating Mode to run your code. Note that you may have to reset your board when switching modes.
Next, wire up your USB-to-UART RX and TX lines with your BluePills A9 and A10 ports. See below.
Then power up your BluePill either through its USB port or in-circuit. The wiring should look something similar below. Don’t forget to connect a common GND line. You can use any commerciallly available USB-to-UART converter as long as it’s outputting a 3.3V level.
Setting-up Programming your Bluepill in Arduino IDE
Make sure you’ve read preparing your Bluepill for Arduino IDE before proceeding.
Define the Upload Method
Next, go to Tools -> Upload Method then choose STM32 Cube Programmer (Serial).
Pick a COM Port
Make sure you pick the COM port of your USB to UART converter accordingly
Create Your Bluepill Program
For starters, try to create a simple Blinky program.
void setup() {
// put your setup code here, to run once:
pinMode(PC13, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(PC13, HIGH);
delay(1500);
digitalWrite(PC13, LOW);
delay(500);
}
Program this in your Bluepill
If needed, press reset, to start your Bluepill first in order to be in bootloader mode and then press Upload in Arduino IDE.
If everything goes well, you should see your code uploaded to your Bluepill using the STM32Cube Programmer plug-in program. You can rearrange the jumper to Normal operating mode and then press reset to run your board permanently in this mode.
SHOP THIS PROJECT
-
ST-Link V2 Mini In-Circuit Programmer and Debugger for STM8 / STM32
$31.95Original price was: $31.95.$16.95Current price is: $16.95. Add to cart