Jay Carlson Hunts Down the Cheapest Flash-Equipped Microcontroller: a Puya 32-Bit Arm Cortex-M0+

While much has been made of low-cost microcontrollers built around RISC-V, Carlson says Arm-based alternatives may be a better choice.

Gareth Halfacree
5 months agoHW101

Embedded systems engineer Jay Carlson has been on the hunt for the lowest-possible-cost microcontroller to feature onboard flash storage — and believes he's found it, in the form of a Puya chip featuring an Arm Cortex-M0+ core.

"Puya? They’re a flash memory company out of Shanghai that’s been around since 2012 — mostly making really low-cost SPI flash memory for IoT [Internet of Things] gadgets," Carlson explains in a blog post brought to our attention by Adafruit. "While it may seem odd that the cheapest MCU [Microcontroller Unit] is made by a flash memory company, if you know a thing or two about chip design (which I don't) you'll know that it’s often the flash memory inside the part that's the most expensive IP in the design."

It's this, Carlson explains, which causes many ultra-low-cost microcontrollers to be built without onboard flash at all, offering instead single-use electronically programmable read-only memory (EPROM) that can only be burned once before having its contents locked forever more. The Puya PY32 range, by contrast, comes with true embedded flash — and a familiar Arm Cortex-M0+ core, rather than the free and open-source RISC-V architecture seen in many of its low-cost rivals.

"At the time of publication, prices have shot up quite a bit compared to when I first ordered these parts," Carlson notes, "but currently, the prices range from less than 8 cents up to $0.74 depending on the exact part, configuration, and quantity you’re buying. The F002A is the base model: it clocks in at 24MHz, has 20k of flash, [and] 3k of SRAM [static RAM].

"It has one advanced-control timer with 4 outputs (plus two complementary pairs for driving H-bridges), 1 low-power timer, 1 general-purpose timer, a 1 MSPS 12-bit ADC with 6 external channels, two comparators, a basic watchdog timer, and one SPI, I2C, and USART peripheral. And since this is a Cortex-M0+, you get an SWD debugging interface, a SysTick timer, and a nested vector interrupt controller (NVIC) bundled in."

That's a lot of features in a sub-10¢ chip, but there's more to recommend the parts than just cost. Carlson describes the development experience as relatively smooth, bar a little fiddling to get the software development kit configured for Visual Studio Code rather than Kiel MDK. "Overall, these parts are much easier to use than other parts in this price range," Carlson says, "which often have poor English documentation, no code samples or peripheral libraries, or require vendor-provided IDEs and weird tooling.

"Bottom line: the Puya PY32 ecosystem is just plain boring — and that’s a good thing."

Carlson's full write-up is available on his website; he has also published a sample project on GitHub to serve as a quick-start for others adopting the same chips.

Gareth Halfacree
Freelance journalist, technical author, hacker, tinkerer, erstwhile sysadmin. For hire: freelance@halfacree.co.uk.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles