Schematic Fixes
Audit schematic connectivity and MCU support circuits
Apply focused schematic fixes
Re-run ERC and verify corrected nets
Table
| Function | MCU Pin | Net | Direction | Notes |
|---|---|---|---|---|
| Hour bit 1 | PA0 | LED_H1 | Output | LED through R1 |
| Hour bit 2 | PA1 | LED_H2 | Output | LED through R2 |
| Hour bit 4 | PA2 | LED_H4 | Output | LED through R3 |
| Hour bit 8 | PA3 | LED_H8 | Output | LED through R4 |
| Minute bit 1 | PA4 | LED_M1 | Output | LED through R5 |
| Minute bit 2 | PA5 | LED_M2 | Output | LED through R6 |
| Minute bit 4 | PA6 | LED_M4 | Output | LED through R7 |
| Minute bit 8 | PA7 | LED_M8 | Output | LED through R8 |
| Minute bit 16 | PB0 | LED_M16 | Output | LED through R9 |
| Minute bit 32 | PB1 | LED_M32 | Output | LED through R10 |
| PM/Accent LED | PB10 | LED_AMPM | Output | Optional PM indicator |
| Decorative LED | PB11 | LED_DECOR | Output | Optional flair/status LED |
| Display/Wake button | PB12 | BTN_DISPLAY | Input pull-up | Button shorts to GND |
| Mode button | PB13 | BTN_MODE | Input pull-up | Button shorts to GND |
| Set button | PB14 | BTN_SET | Input pull-up | Button shorts to GND |
| LSE crystal in | PC14 | LSE_IN | Analog clock | 32.768 kHz crystal |
| LSE crystal out | PC15 | LSE_OUT | Analog clock | 32.768 kHz crystal |
| SWDIO | PA13 | SWDIO | Debug | SWD header |
| SWCLK | PA14 | SWCLK | Debug | SWD header |
| Reset | NRST | NRST | Reset | SWD header reset |
platformio.iniIni
[env:genericSTM32L433CB] platform = ststm32 board = genericSTM32L433CB framework = arduino upload_protocol = stlink debug_tool = stlink monitor_speed = 115200 build_flags = -D PIO_FRAMEWORK_ARDUINO_ENABLE_CDC
src/main.cppCpp
#include <Arduino.h> #include <STM32RTC.h> STM32RTC& rtc = STM32RTC::getInstance(); #define LED_H1 PA0 #define LED_H2 PA1 #define LED_H4 PA2 #define LED_H8 PA3 #define LED_M1 PA4 #define LED_M2 PA5 #define LED_M4 PA6 #define LED_M8 PA7 #define LED_M16 PB0 #define LED_M32 PB1 #define LED_PM PB10 #define LED_DECOR PB11 #define BTN_DISPLAY PB12 #define BTN_MODE PB13 #define BTN_SET PB14 const uint8_t hourLedPins[4] = {LED_H1, LED_H2, LED_H4, LED_H8}; const uint8_t minuteLedPins[6] = {LED_M1, LED_M2, LED_M4, LED_M8, LED_M16, LED_M32}; const uint8_t allLedPins[12] = { LED_H1, LED_H2, LED_H4, LED_H8, LED_M1, LED_M2, LED_M4, LED_M8, LED_M16, LED_M32, LED_PM, LED_DECOR }; const uint32_t DISPLAY_TIMEOUT_MS = 5000; uint32_t displayUntil = 0; bool showing = false; void allLedsOff() { for (uint8_t pin : allLedPins) { digitalWrite(pin, LOW); } } void showBinaryTime() { uint8_t hour24 = rtc.getHours(); uint8_t minute = rtc.getMinutes(); bool pm = hour24 >= 12; uint8_t hour12 = hour24 % 12; if (hour12 == 0) hour12 = 12; for (int i = 0; i < 4; i++) { digitalWrite(hourLedPins[i], (hour12 & (1 << i)) ? HIGH : LOW); } for (int i = 0; i < 6; i++) { digitalWrite(minuteLedPins[i], (minute & (1 << i)) ? HIGH : LOW); } digitalWrite(LED_PM, pm ? HIGH : LOW); digitalWrite(LED_DECOR, HIGH); showing = true; displayUntil = millis() + DISPLAY_TIMEOUT_MS; } bool pressed(uint8_t pin) { static uint32_t lastMs = 0; if (digitalRead(pin) == LOW && millis() - lastMs > 180) { lastMs = millis(); return true; } return false; } void incrementHour() { uint8_t h = rtc.getHours(); h = (h + 1) % 24; rtc.setHours(h); } void incrementMinute() { uint8_t m = rtc.getMinutes(); m = (m + 1) % 60; rtc.setMinutes(m); rtc.setSeconds(0); } void setup() { for (uint8_t pin : allLedPins) { pinMode(pin, OUTPUT); digitalWrite(pin, LOW); } pinMode(BTN_DISPLAY, INPUT_PULLUP); pinMode(BTN_MODE, INPUT_PULLUP); pinMode(BTN_SET, INPUT_PULLUP); // Use external 32.768 kHz LSE crystal where supported by the board core. rtc.setClockSource(STM32RTC::LSE_CLOCK); rtc.begin(); // First-program default. User can set using MODE/SET buttons. if (!rtc.isTimeSet()) { rtc.setTime(12, 0, 0); rtc.setDate(1, 1, 24); } } void loop() { if (pressed(BTN_DISPLAY)) { showBinaryTime(); } // Simple setting mode while LEDs are awake: // MODE increments hours, SET increments minutes. if (showing && pressed(BTN_MODE)) { incrementHour(); showBinaryTime(); } if (showing && pressed(BTN_SET)) { incrementMinute(); showBinaryTime(); } if (showing && (int32_t)(millis() - displayUntil) >= 0) { allLedsOff(); showing = false; } // For the first revision, keep this simple. Later firmware can enter STOP mode // and wake from EXTI on BTN_DISPLAY for much longer battery life. delay(20); }
pio runpio run -t uploaddelay(20) loop with STM32 STOP mode and wake on the display button EXTI interrupt.Platform & Toolchain
Pin Mapping
`platformio.ini`
`src/main.cpp`
Build & Flash