logo elektroda
logo elektroda
X
logo elektroda

PY32F002 - Chinese ARM for 8 cents from PUYA

piotr_go 32424 77
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • 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>

    Cool? Ranking DIY
    About Author
    piotr_go
    DIY electronics designer
    Offline 
    piotr_go wrote 2840 posts with rating 3190, helped 91 times. Been with us since 2003 year.
  • ADVERTISEMENT
  • #2 20364796
    xHaKeReK
    Level 20  
    Where can I buy them?
  • #4 20364845
    szymon122
    Level 38  
    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. Assuming using the same pins and instructions compatible with both, you can just transfer the program without changing anything but the "target" in the environment?
    Or maybe someone knows direct equivalents, e.g. STM32F405 etc?
  • #5 20364881
    ZbeeGin
    Level 39  
    szymon122 wrote:
    So I'm surprised that all the Chinese "toys" are still on modern '51 versions.

    Apparently, they assume that there is no need for "sparrow cannons" (Jż once was action with sparrows).
  • #6 20364941
    Galareta
    Level 23  
    Because '51s are 4 cents, not 8 ;) And they have programs ready for years.
  • #7 20364989
    interbudtr
    Level 6  
    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.
  • ADVERTISEMENT
  • #8 20365201
    piotr_go
    DIY electronics designer
    szymon122 wrote:
    So I'm surprised that all the Chinese "toys" are still on modern '51 versions.

    More and more ARM or RiscV, but 8-bit for 2 cents probably won't disappear.

    interbudtr wrote:
    It is a pity that such microcontrollers are not available on ali.

    They are PY32F003, just the price is ridiculous.

    interbudtr wrote:
    If I were to order only this microcontroller with lscs, it would still be cheaper to get something on the local market

    I usually order with tiles, then I get free shipping.
  • #9 20365649
    gulson
    System Administrator
    szymon122 wrote:
    So I'm surprised that all the Chinese "toys" are still on modern '51 versions.

    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.
    In addition, the semiconductor market is to receive billions of dollars / euros / yuan from all governments, so probably the processors will lie on the street, and each continent will produce its own (end of globalization in semiconductors). We are facing a real arms race, not only on prices. Designers and engineers will win.
  • #10 20365941
    Macosmail
    Level 35  
    gulson wrote:
    We are facing a real arms race, not only on prices. Designers and engineers will win.

    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.

    In many products where STM32 used to be present, now you can often find Chinese substitutes. Of course, this does not only apply to the STM32F103, the offer of these Chinese manufacturers is wide.
    PY32F002 - Chinese ARM for 8 cents from PUYA
    PY32F002 - Chinese ARM for 8 cents from PUYA PY32F002 - Chinese ARM for 8 cents from PUYA PY32F002 - Chinese ARM for 8 cents from PUYA PY32F002 - Chinese ARM for 8 cents from PUYA PY32F002 - Chinese ARM for 8 cents from PUYA PY32F002 - Chinese ARM for 8 cents from PUYA PY32F002 - Chinese ARM for 8 cents from PUYA
    PY32F002 - Chinese ARM for 8 cents from PUYA
    Even the ATmega328 has its replacement LGT328, interestingly optimized so that most instructions that needed more than 1 cycle are executed twice as fast at the same clock. There are also some improvements in the periphery.
  • #11 20366078
    krisRaba
    Level 31  
    piotr_go wrote:
    There is an SWD interface, so you don't need some exotic programmer.

    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 :)
  • ADVERTISEMENT
  • #12 20366079
    jarekgol
    Level 39  
    Galareta wrote:
    Because '51s are 4 cents
    where do you buy this and how much?
  • ADVERTISEMENT
  • #13 20366259
    l0ud
    Level 14  
    krisRaba wrote:
    piotr_go wrote:
    There is an SWD interface, so you don't need some exotic programmer.

    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 :)

    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 pieces of PY32F003 and I also had some fun.
    What surprised me the most was that the manufacturer did not lie in the documentation about the power consumption. I tested different configurations of the internal oscillator and indeed the values match the datasheet. This microcontroller is really quite frugal and eats 8-bit Atmega and old STM32F0 type STMs for breakfast. With LSI and flash sleep enabled, you can get really low power consumption without sleep.
    A pleasant surprise is also the fact that it is a variant of the core with faster multiplication and single-cycle I/O.

    The most annoying thing was writing a flash driver for OpenOCD and a startup script (the manufacturer provided a startup in the dialect of some closed ARM assembler). After doing these things, the vendor examples work normally on GCC. HAL is probably more or less crap stolen from STM, but well, it works and gives an insight into the periphery.
    I'm surprised how good these MCUs are for such a ridiculous price.
  • #14 20366430
    piotr_go
    DIY electronics designer
    Macosmail wrote:
    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.

    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.
  • #15 20366734
    gulson
    System Administrator
    piotr_go wrote:
    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.

    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.

    Unless they reset us first.

    Well, I need to order some samples.
  • #16 20367996
    Azbi
    Level 10  
    @piotr_go And what environment or sdk do you use to program these PUYAs?
    Because I would love to play with them too :)

    Regards, Azbi
  • #17 20368028
    piotr_go
    DIY electronics designer
    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 system.
  • #18 20368055
    l0ud
    Level 14  
    VSCode works quite well with the Cortex Debug plugin, proper configuration and OpenOCD.
  • #19 20368393
    szymon122
    Level 38  
    Macosmail wrote:
    In many products where STM32 used to be present, now you can often find Chinese substitutes.

    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"?
  • #20 20369548
    Macosmail
    Level 35  
    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 chips took over the naming system from the STM32.
    Ew. changes and improvements are implemented in a "non-collision" way, eg using empty (or reserved) parts of the registers of the original MCU.
    Larger differences may occur in GD32 due to the use of serial Flash memory, from which the program code after starting and waking up from STBY is copied to SRAM, which takes a certain amount of time. In "energy-saving" software, this can be a problem.
    Of course, directly from CubeIDE, you will not be able to program any of these chips, but it is worth trying older versions of the STM32 ST-LINK utility or dedicated Chinese tools, although some are only in Chinese.
  • #21 20375532
    piotr_go
    DIY electronics designer
    I was able to pinpoint the external reset issue a bit more precisely. HardFault appears when accessing AHB/APB.

    Ehhh, they lied in the documentation. PY32F002AA15M6TU has 32kB FLASH and 4kB RAM. :)
    I'm still looking for a DMA...

    =============== update ================

    It looks like there is also DMA.
    I wrote a simple code to send data to SPI and there is a clock on SCK.
    When DMA is turned off, the clock disappears.

    The minimum SPI divider in master mode is 2.
  • #22 20380514
    piotr_go
    DIY electronics designer
    Getting better. There is a PLL in the PY32F002AA15M6TU. :)
    Only bonuses.

    =============== update ================

    I overclocked it to ~96MHz. Simple code from RAM works stably. FLASH won't work (1 is the maximum wait state).
  • #23 20380584
    Macosmail
    Level 35  
    Perhaps these are some defective structures from PY32F003.
    Has anyone managed to find the Reference Manual in English? The catalog cards are in English, and what is most important is not...
    In general, there is a strange situation with this because, for example, here ( http://47.103.60.28:8090/en/download1.aspx ) is similar to uC (although different - and the price is different) and also no RM.
    In general, somewhere I came across information, I do not remember now which manufacturer of the MCU, but to get to the documentation you need to use a VPN :-)
    EDIT:
    Update 2020-06-13: The website is not reachable from Europe. However, using a VPN with an Asian exit point gives access to the website. Even though the website appears only to work when accessed from Asia, the Datasheet is available in English. Besides the datasheet, there are development libraries available, however, I haven't been able to locate a user manual (any documentation discussing the register values). Therefore I state the documentation to be incomplete.
  • #24 20380597
    piotr_go
    DIY electronics designer
    Macosmail wrote:
    Perhaps these are some defective structures from PY32F003.

    PY32F003 (according to PDF) has no PLL.
    Macosmail wrote:
    Has anyone managed to find the Reference Manual in English?

    It is up to PY32F030.
    https://www.puyasemi.com/cpzx3/info_267_aid_242_kid_235.html

    =============== update ================

    2 USARTs, 2 SPI.
    PY32F030 to PY32F002 pack :)
  • #26 20381866
    Macosmail
    Level 35  
    It's for PY32F003 probably too (I ordered it :) ). I wonder if this LED Driver for 7-segment displays is also there. From what I understand, the pins should then be current sources (20-40-60-80mA). With this 10-pin housing in PY32F002, you can have a common first digit cathode on PB3, and a C-segment anode on PA1.
    You could connect an LED and see if you can turn it on and off, change the brightness with current efficiency and multiplexing frequency. Then it would be 99.9% sure that it is PY32F030 :)
    I see the counters and probably most of the peripherals identical to those in STM32 :)
  • #27 20381922
    piotr_go
    DIY electronics designer
    Code: C / C++
    Log in, to see the code

    It gives the result "0x00000078" :)
    Without RCC_APBENR2_LEDEN set it is "0x00000000".

    Tested on PY32F002 in SO8.
  • #28 20381943
    Macosmail
    Level 35  
    The register accepts data (within its 8-bits) after the clock is delivered. So it would probably and physically work :) although the 8-pin package may not have this capability :-)
    From a marketing point of view, perhaps it is better when the manufacturer offers a whole series of chips than just one in different housings :)
  • #29 20382019
    piotr_go
    DIY electronics designer
    I ordered PY32F002 in TSSOP20, QFN16 and SOP16, they should be on their way to me now. Apparently they have C19 at LCSC so there are delays.
    In addition, adapters and various universal plates ...
  • #30 20382088
    jarekgol
    Level 39  
    piotr_go wrote:
    in LCSC they have C19
    what does it mean?

Topic summary

The discussion revolves around the PY32F002 and PY32F003 microcontrollers from PUYA, which feature an ARM Cortex M0+ core and are priced at 8 cents and 16 cents, respectively. Users express interest in purchasing these microcontrollers, with links provided to suppliers like LCSC. The PY32F002 offers 20kB FLASH and 3kB RAM, while the PY32F003 includes additional features like DMA and more timers. The microcontrollers support various interfaces (SPI, USART, I2C, ADC) and have a power supply range of 1.7V to 5.5V. Users discuss programming methods, compatibility with STM32, and the availability of development tools. There are also mentions of challenges in programming and documentation access, particularly for the QFN package. Overall, the conversation highlights the growing interest in low-cost ARM microcontrollers and their potential applications.
Summary generated by the language model.
ADVERTISEMENT