STM8 to STM32C0 or Nuvoton Migration Without Stock Panic
2026-08-28
Your STM8 board works, but stock is 52 weeks or NRND whispers started. Rewriting from scratch feels risky, staying feels riskier. There is a middle path: migrate to STM32C0 or Nuvoton M0 with the same behavior, tested side by side.
STM8S and STM8L still sit in motor starters, meters and panels. ST documents the move to STM32C0 in AN5775. STM32C0 is a 48 MHz Cortex-M0+ and runs far more efficiently per MHz than STM8S in dynamic current per that note. Nuvoton M031 and M032 are a second option when STM32 stock or price hurts.
TL;DR: STM8S003 -> STM32C031C6 or M031SC. STM8L151 -> STM32C071C8 or M032SE. No pin-to-pin, expect re-route. Emulate EEPROM, re-do supply, test old vs new together.
What changes (and what does not)
Core goes from 8-bit STM8 to 32-bit. EEPROM emulation replaces true data EEPROM. Timers, ADC triggers and option bytes all move. Pinout never maps one to one, so expect a re-route even in LQFP48.
From AN5775 (STM8L/S -> STM32C0):
- Core: STM8 8-bit CISC -> Cortex-M0+ 32-bit RISC, 48 MHz max (vs 24 MHz STM8S / 16 MHz STM8L). Faster, larger code size.
- Supply: STM32C0 2.0-3.6 V vs STM8S 5 V (2.95-5.5 V). Single VDD/VSS pair on C0. Level-shift 5 V sensors.
- Tools: STVD + Cosmic/IAR + STVP via SWIM -> STM32CubeIDE + STM32CubeProg via SWD. No SWIM.
- Upward path is STM32C0 -> STM32G0 (C0 series), not STM8 pin-compatible.
Typical mapping we use:
STM8S003F3 -> STM32C031C6 or Nuvoton M031SC
STM8L151C6 -> STM32C071C8 or Nuvoton M032SE
20-pin relay logic -> STM32G030 value line
Datasheets: STM32C031, STM32C071, M031 series, M031/M032 datasheet.
STM32C0 vs Nuvoton M031/M032 table
| Item | STM32C031 | STM32C071 | M031 / M032 |
|---|---|---|---|
| Core | M0+ 48 MHz | M0+ 48 MHz | M0 48 MHz (some 72 MHz) |
| Voltage | 2.0-3.6 V | 2.0-3.6 V + VDDIO | 1.8-3.6 V, 5V-tol |
| Flash / RAM | 16/32 KB + 12 KB | up to 128 KB + 24 KB | 16-512 KB + 2-96 KB |
| ADC | 12-bit 2.5 MSps, 19ch, oversample to 16-bit | Same + more | 12-bit 2 MSPS, 16ch + ACMP |
| Timers | 8x: adv + 4x GP 16-bit | 9x: +32-bit | 4x 32-bit + 24-ch PWM 96/144 MHz |
| Comms | I2C FM+, 2x USART, SPI 24M + I2S | + USB FS crystal-less (C071) | 4x UART + USCI flex (10x UART), QSPI, EBI; M032 + USB FS |
| Packages | 20-48 pin | 20-64 pin | TSSOP20/28, QFN33, LQFP48/64/128 |
| Debug/ID | SWD, CRC, 96-bit UID | + securable area | Nu-Link SWD, ISP/IAP, 96-bit UID + 128-bit UCID |
Takeaway: C071 is strict superset of C031 for memory/USB/DMA/32-bit timer. M031 trades M0+ for M0 + HW divider, lower 1.8 V min, richer UART/USCI + high-freq PWM + ACMP, much larger flash options. If you need 4 UARTs or 144 MHz PWM, Nuvoton wins. If you need Cube/HAL + STM32 supply chain, C0 wins.
EEPROM: the silent killer
STM8S003 has 128 B true data EEPROM, 100k cycles, byte-erasable (STM8S003F3). STM32C0 and M031/M032 have none. You must emulate.
- STM32C0: Flash emulation via AN4894 / X-CUBE-EEPROM. Needs >=2 flash pages, wear-leveling, background page-erase, power-fail robustness. Size endurance by
variables x cyclesformula. Shared-flash + cache handling required. - Nuvoton: Data Flash shared with APROM + LDROM/APROM IAP + Config Words + SPROM. Reserve APROM Data Flash + ISP/IAP wear-leveling in software.
Rules: never write on every loop — write on change + timer. Keep a RAM shadow + dirty flag. Test 200x power-cut during page-erase; half our field bugs live here.
Timers/ADC port: STM8 TIM1 adv + TIM2 16-bit + TIM4 8-bit + 10-bit ADC -> C0 TIM1 adv + 4x GP 16-bit + 12-bit 0.4 us ADC, or M031 4x 32-bit + 96/144 MHz PWM + 12-bit 2 MSPS. Re-tune PWM deadtime and ADC trigger (timer TRGO) — numbers do not copy.
Option bytes: STM8 ROP/WP/UBC via STVP/SWIM -> C0 RDP L0/L1/L2 + WRP + BOR + nBOOT via SWD/CubeProg, Nuvoton CONFIG0/1/2 + SPROM via ICP/ISP. Rewrite protection/boot logic from scratch.
How we rebuild without breaking behavior
First we read out what exists. If the chip is locked we rebuild from behavior: supply, relay sequence, timing, thresholds. Then we redraw the schematic in KiCad, port the logic to STM32Cube or Nuvoton BSP, and test on a new board against the original unit side by side.
Do not clone the old supply as is. Old RC dropper or linear stages waste the savings from the new MCU. A small buck or a modern LDO pays back in heat alone.
Steps:
- Photos both sides + old hex if unlocked. Logic analyzer capture of relay/UART/PWM sequences.
- New schematic: 3.3 V buck, SWD header, NRST, proper decoupling, 5 V-tolerant check.
- Port: CubeMX or Nuvoton BSP, HAL only where timing allows, LL/direct for ISR-critical.
- Side-by-side rig: old vs new on same input, scope outputs, 72-hour soak + temperature.
- Stock: dual-source C0 + M031 footprints where possible (QFN/LQFP48 overlap plan).
If your new board also needs low sleep, apply STM32U3 Stop thinking or nRF54L15 OFF+GRTC patterns to the new MCU — same GPIO-latch + small-retention rules.
FAQ
Cheapest STM8S003 replacement? STM32C031C6 or M031SC in TSSOP20/LQFP48. C031 for Cube ecosystem, M031 for price + UART count.
Can I keep 5 V supply? No direct. C0 max 3.6 V, M031 max 3.6 V (5V-tolerant I/O only). Add buck + level shift. Do not resistor-divider analog.
What about code size? M0+ code is larger than STM8 for same C. Size flash 2x (16 KB STM8 -> 32 KB C0) and keep bootloader + EEPROM emulation pages spare.
How long does migration take? 2-4 weeks for relay/meter logic with side-by-side test. Add 2 weeks if true EEPROM + power-fail safety is critical.
References
- AN5775 STM8->STM32C0 — https://www.st.com/resource/en/application_note/an5775-migration-of-applications-from-the-stm8l-and-stm8s-series-to-the-stm32c0-series-microcontrollers-stmicroelectronics.pdf
- STM32C031 datasheet — https://www.st.com/resource/en/datasheet/stm32c031c4.pdf
- STM32C071 datasheet — https://www.st.com/resource/en/datasheet/stm32c071c8.pdf
- STM32C0 series — https://www.st.com/en/microcontrollers-microprocessors/stm32c0-series.html
- Nuvoton M031 series — https://www.nuvoton.com/products/microcontrollers/arm-cortex-m0-mcus/m031-series
- M031/M032 datasheet — https://www.nuvoton.com/export/resource-files/DS_M031_M032_Series_EN_Rev2.02.pdf
- AN4894 EEPROM emulation — https://www.st.com/resource/en/application_note/an4894-how-to-use-eeprom-emulation-on-stm32-mcus-stmicroelectronics.pdf
- STM8S003F3 — https://www.st.com/en/microcontrollers-microprocessors/stm8s003f3.html
Send photos of both sides of your board plus the old hex if you have it. We reply with a migration target and cost.