logo elektroda
logo elektroda
X
logo elektroda

PY32F002 - Chinese ARM for 8 cents from PUYA

piotr_go 
Two purple modules with PUYA ARM Cortex M0+ microcontrollers. Three PUYA PY32F series microcontrollers on purple development boards with green and black connectors.

There was already an ARM for 16 cents , now we have ARM for 8 cents. Yes, eight. :)
PY32F002/PY32F003 from PUYA are microcontrollers with ARM Cortex M0+ core clocked at 24/32MHz.
PY32F002 have 20kB FLASH, 3kB RAM, SPI, USART, I2C, ADC, timers... nothing to complain about.
PY32F003 additionally DMA and a few more timers, there is also a larger choice of memory.
There is an SWD interface, so you don't need some exotic programmer.
Power supply 1.7V...5.5V.
Packages from standard SOPs, through TSSOPs, to small QFNs or DFNs.

Downloadable PDFs on the Chinese version of the site:
https://www.puyasemi.com/cpzx3/info_267_aid_242_kid_235.html
Click on the orange folder. Each has the same RAR with a bunch of PDFs and other aids. Some in Chinese, some in English.

PY32F002:
Block diagram of the ARM Cortex M0+ microcontroller.
PY32F003:
Block diagram of ARM Cortex M0+ microcontroller PY32F002/PY32F003.

Examples of enclosures:
Pin diagrams for PY32F002 and PY32F003 microcontrollers in SOP8, ESSOP10, SOP16, and TSSOP20 packages. Pinout diagram of the PY32F002AW15U microcontroller in QFN16 package. Pinout diagram of the PY32F003W1XS microcontroller in SOP16 package Top view of the DFN8 PY32F003L2XD chip with labeled pins

Hello world (sources attached):
Purple board module with a microcontroller and attached wires.
Flashing LEDs and text on UART (9600 bps)

Tests:
From what I've noticed there are a few issues with the reset.
1. When connecting a button to the RESET pin sometimes a HardFault interrupt appears after pressing it.
The external reset can be disabled so that the problem is rather small. I haven't used an external reset in a long time.
2. The system can be overclocked about 2 times by setting the "wait state" of the flash to 1 and changing the calibration of the generator.
The only problem is that the reset resets the "wait state" of the flash, not resets the generator calibration.
If someone wants to overclock, don't reset.

The current consumption in sleep mode is about 5uA, so I wouldn't call it an 8-bit killer. Comparing the prices... :)

Programming:
To add support for PUYA chips to J-Link, upload the ".FLM" files from the attachment to the "/opt/SEGGER/JLink/Devices/Puya/" directory and add the following to the "JLinkDevices.xml" file:
Quote:
<!-- -->
<!-- Puya -->
<!-- -->
<Device>
<ChipInfo Vendor="ST" Name="PY32F002Ax5" WorkRAMAddr="0x20000000" WorkRAMSize="0xC00" Core="JLINK_CORE_CORTEX_M0"/>
<FlashBankInfo Name="FLASH" BaseAddr="0x08000000" MaxSize="0x5000" Loader="Devices/Puya/PY32F0xx_20.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
<FlashBankInfo Name="OPT" BaseAddr="0x1FFF0E80" MaxSize="0x10" Loader="Devices/Puya/PY32F0xx_OPT.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
</Device>
<Device>
<ChipInfo Vendor="ST" Name="PY32F003x4" WorkRAMAddr="0x20000000" WorkRAMSize="0x800" Core="JLINK_CORE_CORTEX_M0"/>
<FlashBankInfo Name="FLASH" BaseAddr="0x08000000" MaxSize="0x4000" Loader="Devices/Puya/PY32F0xx_16.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
<FlashBankInfo Name="OPT" BaseAddr="0x1FFF0E80" MaxSize="0x10" Loader="Devices/Puya/PY32F0xx_OPT.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
</Device>
<Device>
<ChipInfo Vendor="ST" Name="PY32F003x6" WorkRAMAddr="0x20000000" WorkRAMSize="0x1000" Core="JLINK_CORE_CORTEX_M0"/>
<FlashBankInfo Name="FLASH" BaseAddr="0x08000000" MaxSize="0x8000" Loader="Devices/Puya/PY32F0xx_32.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
<FlashBankInfo Name="OPT" BaseAddr="0x1FFF0E80" MaxSize="0x10" Loader="Devices/Puya/PY32F0xx_OPT.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
</Device>
<Device>
<ChipInfo Vendor="ST" Name="PY32F003x8" WorkRAMAddr="0x20000000" WorkRAMSize="0x2000" Core="JLINK_CORE_CORTEX_M0"/>
<FlashBankInfo Name="FLASH" BaseAddr="0x08000000" MaxSize="0x10000" Loader="Devices/Puya/PY32F0xx_64.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
<FlashBankInfo Name="OPT" BaseAddr="0x1FFF0E80" MaxSize="0x10" Loader="Devices/Puya/PY32F0xx_OPT.FLM" LoaderType="FLASH_ALGO_TYPE_OPEN" AlwaysPresent="1"/>
</Device>

About Author
piotr_go
piotr_go wrote 2834 posts with rating 3186 , helped 91 times. Been with us since 2003 year.

Comments

Add a comment
xHaKeReK 03 Jan 2023 01:35

Where can I buy them? [Read more]

piotr_go 03 Jan 2023 01:47

https://www.lcsc.com/products/Microcontroller-Units-MCUs-MPUs-SOCs_11329.html?keyword=py32f0 [Read more]

szymon122 03 Jan 2023 06:29

So I'm surprised that all the Chinese "toys" are still on modern '51 versions. Regarding Chinese systems, maybe someone knows what it looks like with compatibility, e.g. HC32F460KCTA and STM32F446RC.... [Read more]

ZbeeGin 03 Jan 2023 07:53

Apparently, they assume that there is no need for "sparrow cannons" (Jż once was action with sparrows). [Read more]

Galareta 03 Jan 2023 09:13

Because '51s are 4 cents, not 8 ;) And they have programs ready for years. [Read more]

interbudtr 03 Jan 2023 09:55

It is a pity that such microcontrollers are not available on ali. If I were to order only this microcontroller with lscs, it would still be cheaper to get something on the local market. [Read more]

piotr_go 03 Jan 2023 12:20

More and more ARM or RiscV, but 8-bit for 2 cents probably won't disappear. They are PY32F003, just the price is ridiculous. I usually order with tiles, then I get free shipping. [Read more]

gulson 03 Jan 2023 16:52

Someone wrote a toy program 20 years ago and they just keep using it. It's a matter of time and they will do it on ARMs. Changes are happening right before our eyes, at least in terms of prices. ... [Read more]

Macosmail 03 Jan 2023 19:24

Let's hope, although in the context of the recent flood of messages, how ChatGPT spits out programs based on a verbal description, you can feel confused if it's all going in the right direction. ... [Read more]

krisRaba 03 Jan 2023 20:22

It's a big advantage. In many solutions, the contortions needed to run the environment are an obstacle with limited time. Glad they're going this way :) [Read more]

jarekgol 03 Jan 2023 20:23

where do you buy this and how much? [Read more]

l0ud 03 Jan 2023 21:46

This is "free" resulting from the use of the Cortex M core. There was no point in inventing something of our own, so we got the compatibility for free. Recently, I became the owner of several hundred... [Read more]

piotr_go 03 Jan 2023 23:39

In 20 years, you will dictate the description to your smartphone, and after a week you will receive a ready assembled and programmed system. It twists me. [Read more]

gulson 04 Jan 2023 09:41

Maybe not in 20 years, but in 10 years. And not only a ready assembled system, but possibly the whole device with a housing printed on a 3D printer ;) Interestingly, everything will be completely automated. ... [Read more]

Azbi 04 Jan 2023 21:08

@piotrgo And what environment or sdk do you use to program these PUYAs? Because I would love to play with them too :) Regards, Azbi [Read more]

piotr_go 04 Jan 2023 21:26

Regular editor with syntax highlighting and multiple tabs. It goes with everything. I was tired of so many different scales that I got used to it. In addition, GCC / SDCC / or whatever it is for a given... [Read more]

l0ud 04 Jan 2023 21:39

VSCode works quite well with the Cortex Debug plugin, proper configuration and OpenOCD. [Read more]

szymon122 05 Jan 2023 06:21

What is the compatibility of such programs? I mean, I understand that "hex" will not work, but having the source code, it is enough to compile it using "Chinese tools"? [Read more]

Macosmail 05 Jan 2023 18:47

I'm just keeping an eye on it for now. I have a GD32, but no time to test it yet. As far as I know, in most cases a binary compiled for STM32 should work on a Chinese replacement. After all, these... [Read more]