Electronics > Microcontrollers

$0.11 PY32F002A: Cortex-M0+ MCU, actually a PY32F030! 32/4KB, 48MHz, PLL, DMA...

(1/27) > >>

DavidAlfa:
To avoid bloating my HK32030M thread, I'll be posting the PY32F002A bits here.

Links:
Puya gitee repo: Docs, libs, software...
Puya support pack 1: Docs, libs, ISP software...
Puya support pack 2: Similar contents but newer, has english datasheets & RM.
IOSetting's repo containing py32 template and libs.
MCU-Flash-Tools. Python-based ISP bootloader tool for WCH and PY32 mcus, removing the dependency of Puya-ISP.

Tested so far:
- Bootloader. Pulling PB6 (BOOT0) high before power-on (Or resetting afterwards) enters the embedded bootloader, just like in STM32.
  Connect RX/TX to PA2/PA3, open Puya ISP, everything works.
  Thread showing PuyaISP:  https://www.elektroda.pl/rtvforum/topic3951956.html


- STM32 CubeIDE: The patch works, I was able to program & debug using JLink.
  CubeIDE Patch adding support for several devices, including PY32.
  PY32 folder with docs and CubeIDE PY32F030 sample project. Patch must be applied before attempting to open this project, otherwise CubeIDE will crash.

  Jlink doesn't support this chip yet so you must manually add it. Place IOSetting's PY32 folder following this instructions:

--- Quote ---OS                     Location
Windows             C:\Users\<USER>\AppData\Roaming\SEGGER\JLinkDevices
Linux                  $HOME/.config/SEGGER/JLinkDevices
macOS               $HOME/Library/Application Support/SEGGER/JLinkDevices

--- End quote ---
Alternatively, you can convert a ST-Link into JLinkEDU, but it will block any attempts to use non-ST devices.
The solution is to edit the XML file and change the vendor to ST (ChipInfo Vendor="ST" ).
But if the device already exists in Jlink software, then you must change the device name, for example "_py32f002af15p6".
Then set this device name under Jlink configuration.
DO NOT do this for commercial purposes. Most people can't afford $100 programmers to just blink some leds.

So far this chip seems to contain the same die as the PY32F030x6, with the same 4/32KB. PLL, DMA, 2nd UART & SPI...
More info: https://www.elektroda.com/rtvforum/topic3946116.html

Tested so far:
 - 32KB flash
 - 4KB RAM
 - PLL (48MHz)
 - 2xSPI, 2xUSART
 - DMA

After setting RDP1, I could no longer program or erase it with J-Link, I had to use PUYA ISP, setting BOOT=1 to enter the serial bootloader and running "Clear chip".


Edit: Fix PCB:
- Missing GND trace for CH340E !!
- CH340E RTS/DTR not working as expected, removed them.
- Fix BOOT0 button, pull pin high instead low.


--- Quote ---Basic BOM:

CH340E
PY32F002AF15P6TU
HK32F030MF4P6
SX3M32.000M20F30TNN
TYPE-C-31-M-12
ME6211A33PG-N
1N5819WT
HS91L02W2C01
XL-3216RGBC
CTS-3425J-V-TR

--- End quote ---
Rest are common parts easily sourced anywhere, 0402 resistors / capacitors, pin headers, 25xx/24xx memories...

The board doesn't need to be fully populated. Actually just the LDO and few caps and you'll have a working board.
You can add the rest of functionalities depending on your needs.


I also extracted the factory bootloader located at 0x1FFF0000, just in case anyone wants to tinker with it in Ghidra/IDA.

DavidAlfa:
The USART2 is definitely there!
I'm toggling the pin AF before transmitting, PA2 AF1=TX1, AF4=TX2.

Edit:
Confirmed the PLL is also present and works, the system boosts to 48MHz.
Overclockability beyond this point is weak, not reaching even 64MHz without crashing.
Could It be the reason it's being sold as a 24MHz part? Perhabs.
As stated in the Elektroda thread, the HSI TRIM value is not restored on system reset, so be careful (PLL has no issues here).


Edit2: Also DMA works. This chip has an amazing value for the cost!

prosper:
i played with iosetting's environment and its examples, and can confirm that the 002 can be treated as an 030. pll, dma, flash, and sram were tested and work for me.

DavidAlfa:
I finished adding CubeIDE support for all PY32F0xx devices.
Updated the CubeIDE patch and added a PY323F030 sample project in the main message.
IOSetting's LL libraty worked great after setting the project up.

iMo:
Does the IDE support double precision floating point math on this device?

Navigation

[0] Message Index

[#] Next page

There was an error while thanking
Thanking...
Go to full version
Powered by SMFPacks Advanced Attachments Uploader Mod