The PY32F0xx series is the entry-level line of Puya's microcontroller family. Based on the ARM Cortex-M0 core, it targets applications that need reliable 32-bit processing at a price point competitive with 8-bit microcontrollers.
PY32F0xx Overview
The PY32F0xx series microcontrollers are based on the ARM Cortex-M0 core running at up to 48 MHz. They are designed for:
- Cost-sensitive embedded applications
- IoT sensor nodes
- Consumer electronics
- Simple industrial control
+---------------------------------------------+
| PY32F0xx Block Diagram |
| |
| ARM Cortex-M0 Flash Memory |
| (up to 48 MHz) <--> (32–256 KB) |
| |
| SRAM (2–32 KB) <--> AHB Bus |
| |
| APB Peripherals: |
| GPIO, USART, SPI, I2C, ADC, DAC |
| Timers, DMA, Watchdog, RTC |
+---------------------------------------------+
PY32F0xx Peripheral Set
Every PY32F0xx variant includes a comprehensive set of integrated peripherals:
GPIO (General Purpose Input/Output)
- Configurable as digital input or output
- Multiple modes: floating input, pull-up, pull-down, push-pull output, open-drain output
- Alternate function mode for peripheral pins
- External interrupt capability on any GPIO pin
ADC (Analog-to-Digital Converter)
- 12-bit resolution — values range from 0 to 4095
- Multiple input channels shared with GPIO pins
- Configurable sampling time per channel
- Software and hardware trigger support
- Single conversion and continuous conversion modes
DAC (Digital-to-Analog Converter)
- Generates analog output voltage from digital values
- Applications: audio output, reference voltage generation, analog waveform synthesis
Timers
- General-purpose timers for time-based events
- Advanced timers with PWM output for motor control and LED dimming
- Basic timers for precise delay generation
- Input capture mode for frequency measurement
USART (Universal Synchronous/Asynchronous Receiver/Transmitter)
- Full USART (not just UART) — supports synchronous mode
- Configurable baud rate, word length, parity, and stop bits
- Hardware flow control (RTS/CTS)
SPI (Serial Peripheral Interface)
- High-speed synchronous serial communication
- Master and slave operation
- Configurable clock polarity and phase (all four SPI modes)
- DMA support for large transfers
I2C (Inter-Integrated Circuit)
- Standard mode (100 kHz) and Fast mode (400 kHz)
- 7-bit and 10-bit addressing
- Multi-master support
- Interrupt-driven and DMA transfers
PWM (Pulse Width Modulation)
- Multiple PWM channels via timer peripherals
- Used for motor control, LED brightness, servo positioning, and buzzer tones
DMA (Direct Memory Access)
- Transfers data between peripherals and memory without CPU involvement
- Reduces CPU load for high-throughput operations (UART, SPI, ADC)
Watchdog Timer
- Resets the system if firmware hangs or enters an infinite error loop
- Independent watchdog operates even when the main clock fails
Pin Layout Organization
Pin assignments vary by specific PY32F0xx model number, but the general structure is consistent:
Power Pins
| Pin | Description |
|---|---|
| VDD / VCC | Digital power supply (1.7V – 3.6V) |
| VSS / GND | Digital ground |
| VDDA | Analog power supply for ADC and DAC |
| VSSA | Analog ground reference |
GPIO Pins
GPIO pins are arranged in ports (GPIOA, GPIOB, GPIOF) and can be reassigned to peripheral alternate functions:
- USART pins: TX, RX (alternate function on GPIO)
- SPI pins: MOSI, MISO, SCK, NSS (alternate function on GPIO)
- I2C pins: SCL, SDA (alternate function on GPIO)
- ADC pins: Dedicated analog input channels
- PWM pins: Timer output channels
Serial Communication Pins
| Interface | Signal | Typical Pin |
|---|---|---|
| USART | TX | PA1, PA9 |
| USART | RX | PA0, PA10 |
| SPI | MOSI | PA7 |
| SPI | MISO | PA6 |
| SPI | SCK | PA5 |
| SPI | NSS | PA4 |
| I2C | SCL | PA3, PF1 |
| I2C | SDA | PA2, PF0 |
Debug Interface Pins
| Signal | Pin | Description |
|---|---|---|
| SWD_IO | PA13 | SWD data |
| SWD_CLK | PA14 | SWD clock |
| NRST | PF2 | Reset pin |
External Interrupt Pins
All GPIO pins can be configured as external interrupt sources. The EXTI (External Interrupt) controller maps GPIO pins to interrupt lines, supporting:
- Rising edge trigger
- Falling edge trigger
- Both edges trigger
PY32F0xx Firmware Examples
Official firmware examples and HAL library are available from the OpenPuya GitHub repository:
https://github.com/OpenPuya/PY32F0xx_Firmware/tree/master/Projects
The repository contains examples for:
| Example | Description |
|---|---|
GPIO_OutputHigh | Basic GPIO output control |
USART_Printf | UART serial output |
ADC_SingleConversion | Single ADC channel reading |
SPI_FullDuplexMasterIT | SPI with interrupts |
I2C_TwoBoards | I2C master/slave communication |
TIM_PWM | PWM generation |
PWR_STOP_WakeUpByLPTIM | Low-power stop mode |
PY32F0xx Variant Comparison
| Part Number | Flash | RAM | Pins | Package |
|---|---|---|---|---|
| PY32F002A | 20 KB | 3 KB | 20 | TSSOP20, SOP8 |
| PY32F003 | 32 KB | 4 KB | 20 | TSSOP20 |
| PY32F030 | 64 KB | 8 KB | 32–64 | QFN32, LQFP64 |
For most simple IoT applications, the PY32F003 (32 KB flash, 4 KB RAM, TSSOP20) provides sufficient resources.
Final Thoughts
The PY32F0xx series delivers ARM Cortex-M0 capability in an affordable, well-integrated package. Its peripheral set covers the needs of most IoT and embedded applications, and the growing community around OpenPuya is expanding the available firmware examples and HAL support.
The combination of a mature ARM toolchain, standard SWD debugging, and a comprehensive peripheral set makes the PY32F0xx a practical choice for cost-sensitive designs.
PY32F0xx: ARM Cortex-M capability at a price that changes what is possible in high-volume embedded design.