目录
普冉PY32系列(一) PY32F0系列32位Cortex M0+ MCU简介
普冉PY32系列(二) Ubuntu GCC Toolchain和VSCode开发环境
普冉PY32系列(三) PY32F002A资源实测 – 这个型号不简单
普冉PY32系列(四) PY32F002A/003/030的时钟设置
普冉PY32系列(五) 使用JLink RTT代替串口输出日志
普冉PY32系列(六) 通过I2C接口驱动PCF8574扩展的1602LCD
PY32F0系列上市其实相当长一段时间了, 样品已经吃灰很久, 因为工作原因11月12月都很忙一直没时间, 最近终于有一点时间把功课做了.
PY32F0 简介
PY32F0 属于 32位 M0 内核的MCU, 配置上有 16KF+2KR, 20KF+3KR, 32KF+4KR, 64KF+8KR 这些组合, 根据外设的丰富程度分成了 PY32F002, PY32F003, PY32F030, PY32F072 这四个系列, 基础的外设 ADC, TIM, SPI, I2C, UART 都有, 除了002, 其它系列都带DMA支持, 1元左右的价格在市场上非常有性价比.
开发上, 因为是通用的 32位 M0内核, 可以在Keil5, IAR, VScode 等IDE上开发, 使用 STLink, DAPLink 或 JLink 烧录和调试.
官网产品页: https://www.puyasemi.com/cpzx3/info_267_aid_242_kid_235.html
从产品页上可以下载最新的资料包, 资料包里包含全部型号的数据手册, 使用手册, 以及代码库, 代码示例, 当前的后缀是 20221117, 里面甚至有页面上没列出来的002A和072的资料.
芯岭科技 XL32F003
芯岭科技的 XL32F003 系列与 PY32F003 属于同内核产品. XL32F003 提供 4×4 脚间距0.4mm 的QFN32封装, 这个封装在 PY32F0 系列中没有, 如果需要超小封装的可以考虑.
PY32F0 各系列具体配置对比
零售能见到的是 PY32F002A, PY32F003, PY32F030, 最后一个072还没见到实物. 从对寄存器的读写测试看, PY32F002A, PY32F003, PY32F030属于同一个内核的产品, 寄存器设置是通用的, 而 PY32F072 属于另一种内核, 因为在002A/003/032上读写072的寄存器地址无效.
每个系列的封装变化很多, 就算一个TSSOP20, 都有三四种引脚布局, 这里不按型号介绍了, 大致看一下各系列的容量和外设区别.
PY32F002 系列
20K Flash, 3K RAM, 这个系列没有见到实物, 只能从启动文件和连接脚本判断一下具体的外设
PY32F002A 系列
32-bit ARM® Cortex® – M0+ CPU
Up to 32 MHz operating frequency
Internal 8 / 24 MHz RC Oscillator (HSI)
Internal 32.768 KHz RC oscillator (LSI)
4 to 24 MHz crystal oscillator (HSE)
Maximum 20 Kbytes of flash memory
Up to 3 Kbytes SRAM
1 x 12-bit ADC
Supports up to 9 external input channels
1 x 16bit advanced control timer (TIM1)
1 x general purpose 16-bit timers (TIM16)
1 x low-power timer (LPTIM), supports wake-up from stop mode
1 x Independent Watchdog Timer (IWDT)
1 x SysTick timer
1 x Serial Peripheral Interface (SPI)
1 x Universal Synchronous / Asynchronous Transceivers (USARTs) with automatic baudrate detection
1 x I2C interface , supports standard mode (100kHz) , Fast mode (400 kHz) , supports 7-bit addressing mode
Hardware CRC-32 module
Comparator * 2
Unique UID
Serial wire debug (SWD)
Operating voltage: 1.7V to 5.5V
Working temperature: -40℃ to 85℃
Package: SOP8, SOP16, ESSOP10, TSSOP20, QFN16
大致的资源描述: 宽电压1.7V到5.5V, 最高支持32MHz时钟, 内建24MHz, 最高20KB的flash, 3KB的SRAM, 带ADC, TIM, 低功耗TIM, WDT, SPI, UART, I2C, 还带两个比较器.
宽电压这点很强, 3.3V和5V都覆盖了
存储也还不错, 相比 HK32F030MF4P6 和 CH32V003 的 16KB flash + 2KB RAM 容量更高
该有的外设都有, 如果能带个I2S就更好(😄)
比较器在有些场景下很有用, 省了外接了.
和 PY32F002 的区别:
增加了比较器
少了TIM6? 从启动文件比较看不出区别, 这个不确定
PY32F003 系列
32-bit ARM® Cortex® – M0+ CPU
Up to 32 MHz operating frequency
Internal 4 /8/16/ 22.12 / 24 MHz RC Oscillator (HSI)
Internal 32.768 KHz RC oscillator (LSI)
4 to 32 MHz crystal oscillator (HSE)
Maximum 64 Kbytes of flash memory
Up to 8 Kbytes SRAM
3-channel DMA controller
1 x 12-bit ADC
Supports up to 10 external input channels
1 x 16bit advanced control timer (TIM1)
4 x general purpose 16-bit timers (TIM3/TIM14/TIM16/TIM17)
1 x low-power timer (LPTIM), supports wake-up from stop mode
1 x Independent Watchdog Timer (IWDT)
1 x Window Watchdog Timer (WWDT)
1 x SysTick timer
RTC
1 x Serial Peripheral Interface (SPI)
2 x Universal Synchronous / Asynchronous Transceivers (USARTs) with automatic baudrate detection
1 x I2C interface , supports standard mode (100kHz) , Fast mode (400 kHz) , supports 7-bit addressing mode
Hardware CRC-32 module
2 x comparators
Unique UID
Serial wire debug (SWD)
Operating voltage: 1.7V to 5.5V
Working temperature: -40℃ to 85℃
Package: SOP8, SOP16, TSSOP20, QFN20
和 PY32F002A 的区别
频率增加到最高 32MHz
Flash容量增加到最高 64 KBytes
RAM容量增加到最高 8 KBytes
增加了 DMA
增加了 WWDG
增加了 RTC
增加了 TIM3, TIM14, TIM17
增加了 USART2
XL32F003 系列
这是芯岭科技出的一个型号系列, 放在这里是因为这个系列本质上和PY003系列是一样的, 但是只有64KF, 8KR的规格, 当前有三种封装:
TSSOP20: XL32F003TS20, 引脚布局和 PY32F003F2xP 系列一致
QFN20: XL32F003Q20, 引脚布局和 PY32F003F1xU, PY32F030F2xU 系列一致
QFN32: XL32F003Q32, 引脚布局和 PY32F030K2xM 系列一致, 封装更小, 是4×4的QFN, 脚间距0.4mm
PY32F030 系列
32-bit ARM® Cortex® – M0+
Up to 48 MHz operating frequency
Internal 4/8/16/ 22.12/24 MHz RC oscillator (HSI)
Internal 32.768 KHz RC oscillator (LSI)
4 to 32 MHz crystal oscillator (HSE)
32.768KHz low speed crystal oscillator (LSE)
PLL (supports 2 frequency multiplication of HSI or HSE)
Up to 64 Kbytes flash memory
Up to 8 Kbytes SRAM
3-channel DMA controller
1 x 12-bit ADC
Supports up to 10 external input channels
1 x 16bit advanced control timer (TIM1)
4 x general purpose 16-bit timers (TIM3/TIM14/TIM16/TIM17)
1 x low-power timer (LPTIM), supports wake-up from stop mode
1 x Independent Watchdog Timer (IWDT)
1 x Window Watchdog Timer (WWDT)
1 x SysTick timer
RTC
2 x Serial Peripheral Interface (SPI)
2 x Universal Synchronous / Asynchronous Transceivers (USARTs) with automatic baudrate detection
1 x I2C interface , supports standard mode (100kHz) , Fast mode (400 kHz) , supports 7-bit addressing mode
Support 4-bit 7-segment common cathode LED digital tube
Hardware CRC-32 module
2 x comparators
Unique UID
Serial wire debug (SWD)
Operating voltage: 1.7 to 5.5 V
Working temperature: -40℃ to 85℃
Package: LQFP32, QFN32, TSSOP24, TSSOP20, QFN20
和 PY32F003 系列的区别
频率增加到最高 48MHz
支持 两倍PLL
增加了 SPI2
增加了 4位7段 LED数码管驱动
PY32F072 系列
从数据手册看, 与030系列相比Flash和RAM容量提升, 增加了LCD, CTC, TIM2, TIM6, TIM7, TIM15, I2C2, USB等外设. 根据手册上的寄存器测过002A/003/032, 应该是单独的核心, 与前面的三个型号不一样. 因为还未上市, 先不作比较.
文末的彩蛋
PY32F002A 标称是20KB Flash + 3KB SRAM, 但是实际上现在买到的都是 32KB Flash + 4KB SRAM
开发上, 直接使用PY32F030F16的设置就可以了, PY32F030的外设在 PY32F002A 上都有, 已经在 TSSOP20 封装的 PY32F002AF15P 上验证
相关链接
使用GCC ARM 工具链的项目模板 https://github.com/IOsetting/py32f0-template
PY32F003简评 https://zhuanlan.zhihu.com/p/580281296
PY32F003Keil5的环境和ISP工具使用说明 https://blog.csdn.net/firseve/article/details/126661827
Patrick Van Oosterwijck PY32F003 的电压电流曲线 https://silicognition.com/Electronics/PuyaCharge/py32f003-undervoltage-run-mode/
Jay Carlson 对 PY32 系列的介绍https://jaycarlson.net/2023/02/04/the-cheapest-flash-microcontroller-you-can-buy-is-actually-an-arm-cortex-m0/ 和文章的评论 https://brianlovin.com/hn/34660204
Jean-Luc Aufranc (CNXSoft) 对PY32的介绍 https://www.cnx-software.com/2023/02/09/8-cents-for-an-arm-cortex-m0-microcontroller-meet-puya-py32-series-mcus/