clignotante.ino
The blue LED on GD32/Blue Pill boards sits on PC13 and is active LOW — the board's classic "why does it blink backwards" moment. millis() keeps the loop free; the STM32F1 core drives the GD32 as-is.
Hardware required
A GD32F103C8T6 development board (Cortex-M3 at 108 MHz, Blue Pill pin-to-pin compatible), powered at 3.3 V/5 V, with an ST-Link or serial adapter. None: the onboard LED suffices.
Wiring
Nothing to wire (LED on PC13 through 4.7 k). For an external LED: pin through 330 Ω to GND, active-high this time.
How it works
digitalWrite inverts LOW/HIGH to light the active-low LED. The Roger Clark core targets the STM32F103; the GD32F103, a near-binary clone, answers the same code at 108 MHz. With Arduino: install the « STM32F1 » core (Roger Clark, board manager) and pick the « GD32F103C » board; the user LED is PC13 (active LOW). In C: GD32F10x firmware library + ST-Link.
Going further
Two LEDs and a pattern, or the period driven by a potentiometer on PA0 (next sketch).
clignotante.ino
// Clignotement non bloquant — LED bleue sur PC13, activee a LOW.
const int LED = PC13;
const unsigned long PERIODE = 500;
bool etat = false;
unsigned long precedent = 0;
void setup() {
pinMode(LED, OUTPUT);
Serial.begin(115200); // Serial1 = PA9/PA10 (USB-Serie externe)
Serial.println("Clignotement GD32 (108 MHz)");
}
void loop() {
unsigned long t = millis();
if (t - precedent >= PERIODE) {
precedent = t;
etat = !etat;
digitalWrite(LED, etat ? LOW : HIGH); // actif-bas !
Serial.print("tick ");
Serial.println(analogRead(PA0)); // bruit de fond d'un entree flottante
}
}