PUYA Prototype is an open-source printed circuit board by ElectronicCats, from the ElectronicCats/puya-projects repository on GitHub. It is a 2-layer board of 19.3 × 31.8 mm with 26 parts on 13 nets, routed with 120 tracks and 23 vias.
It is built around the PY32F002AA15M6TU and AP2112K-3.3TRG1. Its parts include 3 capacitors, 3 connectors, 2 resistors, 2 ICs and 1 diode.
Add the tool's binary directory to the Windows PATH.
To add the environment variable we look in the windows bar: "Edit environment variables for your account".
Open "Edit environment variables for your account".
Open "Environment Variables...".
Select "Path" and then "Edit...".
Add "New" variable and add the path: "C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\12.3 rel1\bin".
Open the Command Line:
To open the "Command Line" search "cmd" or "PowerShell" in your windows bar. In this case "Windows PowerShell" was used, and a window like the following should open:
Verify GNU Toolchain Installation:
In your Command Line verify if GNU Toolchain Installation was correct.
powershell
&"C:\Program Files (x86)\Arm GNU Toolchain arm-none-eabi\12.3 rel1\bin\arm-none-eabi-gcc" -v
If it has been installed correctly you should obtain a result similar to the following:
Copy the JLinkDevices Directory: Copy [PY32 Directory]/Misc/Flash/JLinkDevices to C:\Users\[User]\AppData\Roaming\SEGGER\JLinkDevices\.
Find the JLink Path: Locate the path where JLink is installed, typically something like: "C:\Program Files\SEGGER\JLink\JLink". Save it for future configurations.
Connect J-Link and Verify: In Windows PowerShell, use the following command to verify the J-Link connection:
powershell
&"C:\Program Files\SEGGER\JLink\JLink"
Open Visual Studio Code:
Open the py32f0-template-project folder.
Adjust Makefile for Your Chip (The "Makerfile" is located in the project folder):
Located in the project folder.
Edit the Makefile to change the tools references, it uses the path references of the previously installed tools.
Tools references.
Edit the Makefile to change all the chip reference to `"PY32F002AX5"`.
Compile the Project:
In Visual Studio Code open a terminal.
Opening a Terminal.
Execute: make -j4 in the Visual Studio Code (VSC) terminal and verify that it compiles correctly, otherwise, it could be that the "Makefile" has not been configured correctly.
Modify the Code:
Open the /User/main.c file.
Adjust pin references from ports B and F to A as needed.
Compile Again: Execute make clean to clean the compilation and after make -j4 to compile with the changes made.
Program the Board: Use make flash to upload the code to your board using J-Link. (You must have your J-Link connected to your computer and with the corresponding connections to the development board)
Save Your Changes: Remember to save the modified files before compiling.
Clean Previous Compilation: If you make changes to the code, run make clean before compiling again.
PUYA Dev Board with the PY32F002AA15M6TU microcontroller should now be configured and ready to go!
The development board can be programmed via SWD by a J-Link (The J-link connections will depend on which J-Link and connector you are going to use).
What is SWD?
SWD is a bidirectional communication protocol that allows for fast and efficient microcontroller debugging and programming.
SWD uses two signal lines, one for data (SWDIO) and one for clock (SWCLK), to communicate with the microcontroller. Through these lines, you can load programs into the microcontroller, stop code execution to inspect variables and debug errors, and perform other debugging operations. It is faster and more efficient than older debugging methods, such as JTAG.
J-Link Connections to the Dev Board
As mentioned earlier, SWD communication involves two key lines: SWDIO for data and SWCLK for the clock signal. However, in addition to these two lines, we also require two more connections:
GND (Ground): This connection is essential to establish a common reference point for electrical potential and ensure proper communication.
VRef (Voltage Reference): In this case, our PUYA Dev board works with a logical voltage level of 3.3V so it is necessary to provide this voltage to the J-Link tool. This voltage, known as VRef, is necessary to support the communication between the J-Link and the target board.
Note: You need to power up the PUYA Dev board with an external 5V power supply.
Instructions to use the J-Link PLUS Compact
To program the PUYA Dev Board with the J-Link PLUS Compact we will need the following components:
USB Cable.
J-Link PLUS Compact.
Dupont Wires.
In addition to this, in order to make the connections we must know what the J-Link pinout is, take the image below as a reference and connect each wire from your PUYA Dev Board to the corresponding one on the J-Link:
J-Link PLUS Compact connector.
Instructions to use the J-Link EDU Mini:
To program the PUYA Dev Board with the J-Link EDU Mini we will need the following components:
USB Cable.
J-Link EDU Mini.
J-Link EDU Mini PCB Adapter.
J-Link EDU Mini Cable.
Dupont Wires.
As shown in the required material, the J-Link EDU Mini PCB Adapter helps us a lot in identifying where we need to connect each wire from our PUYA development board to the PCB adapter. After connecting the corresponding wires you can program your board.
Connection example:
Illustrative image of connections.
The image above is just a reference image of the connections.
The board is being powered directly with 5V and there are the following connections:
Electronic Cats invests time and resources providing this open source design, please support Electronic Cats and open-source hardware by purchasing products from Electronic Cats!
It measures 19.3 × 31.8 mm and has 2 copper layers, 1.6 mm thick.
What parts does the PUYA Prototype use?
26 parts, built around the PY32F002AA15M6TU and AP2112K-3.3TRG1. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
Where can I download the PUYA Prototype KiCad files?
From the ElectronicCats/puya-projects repository on GitHub, at the commit this page was made from: the board is hardware/PUYA_Prototype_PY32F002AA15M6TU/PUYA_Prototype.kicad_pcb and its schematic hardware/PUYA_Prototype_PY32F002AA15M6TU/PUYA_Prototype.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Can I use the PUYA Prototype design in my own project?
Its repository states no licence, so its author keeps all rights: ask ElectronicCats before reusing the design.