🛠 Console série sur USART0 (PA9/PA10)

GD32F103 (GigaDevice) — chip + Blue-Pill-compatible boards · debutant · Schéma : IMG-gd32f103-debutant-3-console-serie-usart0.svg — convertisseur USB-série 3,3 V relié croisé à USART0 : PA9 en TX vers RX de l'adaptateur et PA10 en RX vers TX, masse commune

Objectives

Set up a serial console on USART0 (verified pins: TX on PA9, RX on PA10 on most GD32F103C8 Blue Pill-style boards), send periodic messages, and read back what you type. This is the basic debugging tool: most subsequent tutorials depend on it.

Hardware

Complete code

// console_usart0.ino — GD32F103C8, core CommunityGD32Cores
// Serial = USART0 sur PA9 (TX) / PA10 (RX), comme sur les Blue Pill.
#include <Arduino.h>

uint32_t compteur = 0;

void setup {
  Serial.begin(115200);
  delay(100);
  Serial.println("GD32F103 : console serie prete");
  Serial.println("Envoyez n'importe quel caractere pour l'echo.");
}

void loop {
  if (Serial.available > 0) {
    char c = (char)Serial.read;
    Serial.print("Recu : ");
    Serial.println(c);
  }
  if (compteur % 20 == 0) {
    Serial.print("tick ");
    Serial.println(compteur / 20);
  }
  compteur++;
  delay(50);
}

Expected verification

At 115200 baud, you see "tick 1", "tick 2"… scrolling once per second, and each key pressed is echoed as "Recu : x". If you see constant unreadable characters, it is almost always a wrong baud rate or a missing ground connection.

Common errors

Other tutorials for this board

Code examples for this board

← Back to the board 🛠 All tutorials