Which 10 Cent Microcontroller is Right for You? Comparing the CH32V003 to the PY32F002A.

Zach of All Trades
9 Jun 202427:33

Summary

TLDRIn this video, Zach compares two ultra-budget microcontrollers, the Puya PY32 and WCH CH32V003, both priced around 10 cents. He explores the differences between their cores, the RISC-V of the CH32 and the ARM Cortex-M0+ of the PY32, and their implications for hobbyists and industry. Zach discusses the peripherals, ease of use, and availability, conducting real-world tests including blinking an LED and reading an ADC value. Despite the CH32's faster speed and DMA support, he concludes that the choice between them depends on specific project needs, but for larger quantities and consistent availability, the PY32 might be more suitable.

Takeaways

  • 😀 The video compares the CH32V003 and PY32 microcontrollers, both of which are ultra cheap and cost around 10 cents.
  • 🧩 The CH32V003 features a RISC-V core, an open-source instruction set architecture, while the PY32 uses the ARM Cortex M0+ core, which is proprietary and involves royalties.
  • 📚 The script discusses the importance of considering more than just the processor core when comparing microcontrollers, including memory, peripherals, power systems, and system clocks.
  • 💻 The video mentions that programming microcontrollers is often abstracted by compilers, making the underlying core less critical for many users.
  • 🛠️ The script highlights the lack of documentation for the CH32V003 hardware drivers as a drawback, contrasting with the more extensive resources available for the PY32.
  • 💡 The video suggests that RISC-V could have significant implications for the industry, particularly in academia and for companies looking to integrate processing cores without licensing fees.
  • 🔍 The script notes that the CH32V003 seems to be more popular and has better community support, which can be an important factor for hobbyists and developers.
  • 💰 The video discusses the cost and availability of the microcontrollers, with the PY32 appearing to be more consistently available in larger quantities.
  • 🛒 The script describes the process of setting up and programming both microcontrollers, noting that the CH32V003 was easier to get started with due to better software support.
  • 🏆 The conclusion of the video is that neither microcontroller is definitively better, and the choice between them depends on the specific needs of the project and the availability of the components.

Q & A

  • What are the two ultra cheap flash-based microcontrollers discussed in the video?

    -The two ultra cheap flash-based microcontrollers discussed are the Puya PY-32 and the WCH CH32V003.

  • What is the main difference between the RISC-V core in the CH32 and the ARM Cortex-M0+ core in the PY-32?

    -The RISC-V core is an open-source instruction set architecture, while the ARM Cortex-M0+ core is proprietary intellectual property from ARM, which includes additional resources like hardware models and software tools.

  • Why might the availability of the microcontrollers be a concern for large-scale projects?

    -The availability of the microcontrollers could be a concern for large-scale projects because the CH32V003 was found to have limited stock, which might not be sufficient for bulk requirements, unlike the PY-32 which has shown no such issues.

  • What is the significance of RISC-V for the microcontroller industry according to the video?

    -RISC-V is significant because it allows for free implementation of processors, which can be particularly beneficial for companies, researchers, and hobbyists who might not have otherwise developed their own silicon.

  • What are the advantages of using the CH32V003 over the PY-32F002 based on the video?

    -The CH32V003 has advantages such as a faster clock speed, a DMA controller, and a built-in op-amp. It also has a larger community and more online resources, which can be helpful for support and tutorials.

  • How does the video presenter feel about the open-source nature of RISC-V?

    -The presenter is a huge fan of open-source and believes that RISC-V will have a positive impact on the industry, supporting the idea of freely implementing processors without licensing fees.

  • What is the primary reason the presenter chose the PY-32 for their tile backsplash project despite the availability of the CH32V003?

    -The primary reason was the availability of the PY-32 in sufficient quantities for the project, as the CH32V003 had limited stock which might not meet the requirement of 500 units needed for the project.

  • What is the recommended IDE for programming the CH32V003 according to the video?

    -The recommended IDE for programming the CH32V003 is MounRiver, which is Eclipse-based and feels familiar to those who have used other ARM-based IDEs.

  • What is the main complaint the presenter has about the documentation for the CH32V003?

    -The main complaint is the lack of documentation for the hardware drivers, which makes it difficult to understand how to use certain functions without referring to example code or reading through the drivers themselves.

  • How does the video presenter summarize the choice between the CH32V003 and PY-32F002 for future projects?

    -The presenter suggests that both microcontrollers are useful and have their pros and cons, and the choice between them should be based on the specific requirements of the project. Both are considered valuable options for future projects.

Outlines

00:00

🤖 Introduction to Affordable Microcontrollers

The paragraph introduces a comparison between two ultra-affordable microcontrollers, the Puya PY32 and the WCH CH32V003, both priced around 10 cents. The speaker, Zach, expresses curiosity about whether he made the right choice by purchasing 500 PY32 units for a project. He plans to test the CH32V003 development board, which is the cheapest in the CH32 series and most comparable to the PY32F002, to determine which microcontroller is more suitable for those on a tight budget. The focus is on the core processor differences, with the PY32 using the RISC-V architecture and the CH32 using the ARM Cortex-M0+ core. Zach also discusses the implications of using open-source versus proprietary cores, including licensing and support from ARM for the latter.

05:00

💻 Open-Source RISC-V vs. Proprietary ARM

Zach delves into the differences between the RISC-V and ARM Cortex-M0+ cores, emphasizing RISC-V's open-source nature and ARM's proprietary model. He mentions that while RISC-V is free and open, ARM's model includes royalties and a more comprehensive package that aids in silicon implementation. Zach speculates on the likelihood of Puya's proper licensing of the ARM core, citing the presence of PY32 in Keil uVision, an IDE released by ARM. He also touches on the broader aspects of microcontrollers beyond the core, such as memory, peripherals, and power systems, which can be more critical than the core itself. Zach concludes that for most hobbyists, the choice of core may not significantly impact programming due to the use of high-level languages and compilers that abstract hardware differences.

10:02

🛠️ Practical Considerations for Microcontroller Selection

Zach discusses the practical aspects of choosing a microcontroller, such as cost, ease of use, availability, support, toolchains, and total cost of ownership. He suggests that the 10-cent microcontrollers are best suited for projects requiring a large number of units performing basic tasks, rather than for one-off development boards. He shares his experience with purchasing a development board set that included the CH32V003, a programmer, and chips, and compares it with other options like the STM32 Blue Pill, ESP32S, and Arduino. Zach emphasizes that while cost is a factor, it shouldn't be the only consideration, especially when building products for sale or long-term reliability.

15:03

🔍 Comparing Specifications and Pricing

In this paragraph, Zach compares the specifications and pricing of the CH32V003 and PY32F002 microcontrollers. He notes the CH32's higher clock speed, DMA controller, and built-in op-amp, while the PY32 offers more RAM, Flash memory, and a higher-resolution ADC. Zach also discusses the availability of the microcontrollers on LCSC, with the PY32 appearing to have better stock availability. He mentions that for development boards, the CH32 has more options and is easier to order, giving it an edge over the PY32 in that category. The paragraph concludes with a detailed comparison of features like timers, ADCs, and connectivity options, highlighting the similarities and differences between the two microcontrollers.

20:04

💻 Programming Experience and Documentation

Zach shares his experience programming the CH32V003 using the MounRiver IDE and contrasts it with his experience with the PY32. He finds the CH32's setup in MounRiver to be straightforward, requiring minimal configuration. However, he encounters an issue with interrupt handler attributes that leads to a hard fault, which he resolves with help from online discussions. Zach criticizes the lack of documentation for the CH32's hardware drivers but appreciates the well-written data sheets and reference manuals. He also notes the absence of simple example codes for basic functionalities like timer interrupts and ADC conversions. Despite these challenges, Zach manages to blink an LED and read an analog voltage with the CH32, comparing the ease of use and functionality with the PY32.

25:06

🏆 Conclusion and Future Considerations

Zach concludes the comparison by acknowledging that the choice between the CH32V003 and PY32F002 depends on the specific application requirements. He gives the edge to the CH32 for its out-of-the-box experience with MounRiver, support for the RISC-V movement, hardware features, and the availability of online help. However, he also recognizes the PY32's strengths and notes that he will consider both microcontrollers for future projects. Zach emphasizes the importance of considering factors like stock availability and the potential risks of relying on microcontrollers with limited stock for large projects. He ends by stating that both microcontrollers are valuable and cost-effective, and he plans to continue using them in his work.

Mindmap

Keywords

💡RISC-V

RISC-V is an open-source instruction set architecture (ISA) that is designed to be free and customizable. In the video, the RISC-V core is used in the CH32 microcontroller, contrasting with the proprietary ARM Cortex-M0+ core used in the PY32. The video discusses the merits of open-source ISAs like RISC-V, which allow for more flexibility and freedom in hardware design without the need for royalties, as opposed to ARM's proprietary cores which come with licensing fees.

💡ARM Cortex-M0+

ARM Cortex-M0+ is a 32-bit microcontroller core developed by ARM Holdings. It is a proprietary core that requires licensing fees. In the video, the PY32 microcontroller uses the ARM Cortex-M0+ core, which is highlighted as a point of comparison to the RISC-V core in the CH32. The discussion around it revolves around the licensing and cost implications for manufacturers and the impact on end-users.

💡Microcontroller

A microcontroller is a small computer on a single integrated circuit that includes a processor core, memory, and programmable input/output peripherals. In the video, the terms 'PY32' and 'CH32' refer to specific microcontrollers that are being compared. The video script discusses the features, performance, and cost-effectiveness of these microcontrollers, which are central to the video's theme of evaluating cheap, flash-based microcontrollers.

💡Flash-based Microcontroller

Flash-based microcontrollers are those that use flash memory for non-volatile storage of their firmware. The video focuses on the PY32 and CH32, which are both ultra-cheap flash-based microcontrollers. The script discusses their affordability, which makes them attractive for hobbyists and small-scale projects where cost is a significant factor.

💡Development Board

A development board is a printed circuit board (PCB) that is designed to help in the development of electronic systems. It often includes a microcontroller and various connectors, buttons, and LEDs for prototyping. In the video, the script mentions a development board for the CH32 V003, which is used to test and demonstrate the capabilities of the microcontroller, showing its practical application in a development context.

💡Instruction Set Architecture (ISA)

ISA is the part of the computer architecture that specifies the set of commands (instructions) a processor can execute. The video discusses the RISC-V and ARM Cortex-M0+ ISAs, emphasizing the differences between open-source and proprietary ISAs and their implications for hardware design and software development.

💡Open Source

Open source refers to a type of computer software whose source code is released under a license in which the copyright holder grants users the rights to study, change, and distribute the software to anyone and for any purpose. The video script praises the RISC-V ISA for being open source, allowing for a more flexible and cost-effective approach to microcontroller design and use.

💡Proprietary

Proprietary refers to something that is owned exclusively and the owners can control how it is used. In the context of the video, ARM's Cortex-M0+ core is described as proprietary, meaning it is owned by ARM and its use is subject to licensing agreements and fees. This is contrasted with the open-source nature of RISC-V, which allows for more freedom in its use and distribution.

💡IDE (Integrated Development Environment)

An IDE is a software application that provides comprehensive facilities for software development. In the video, the script discusses the use of MounRiver IDE for programming the CH32 microcontroller. The ease of use of the IDE is a significant factor in the development process, as it can greatly simplify the task of writing, testing, and debugging code.

💡Peripherals

Peripherals in the context of microcontrollers refer to additional functional components that can be connected to the main processor, such as timers, ADCs, communication interfaces, etc. The video script compares the peripherals available on the PY32 and CH32 microcontrollers, discussing how these can affect the choice of microcontroller for a particular project.

💡Cost-effectiveness

Cost-effectiveness in the video refers to the balance between the cost of a microcontroller and the performance or features it offers. The script evaluates the cost-effectiveness of the PY32 and CH32 microcontrollers, considering their price, features, and suitability for different applications, which is a key consideration for many users, especially hobbyists and small-scale manufacturers.

Highlights

Comparison between the CH32V003 and the PY32 microcontrollers, both priced around 10 cents.

Discussion on the merits of the CH32V003 in the comments section of a previous video.

Introduction to the development board for the CH32V003, comparable to the PY32F002.

Core differences between the RISC-V core in the CH32 and the ARM Cortex-M0+ core in the PY32.

RISC-V as an open-source instruction set architecture versus ARM's proprietary core.

Implications of using ARM's intellectual property and potential royalties.

Availability of the PY32 in Keil uVision IDE, suggesting proper licensing from ARM.

WCH's proprietary implementation of the RISC-V architecture in the CH32.

Importance of microcontroller peripherals beyond the processor core.

Programming experience and the abstraction of hardware differences by compilers.

Open-source preference and its impact on software and hardware choices.

Potential benefits of RISC-V for academia and the industry.

Considerations beyond cost when choosing microcontrollers, such as ease of use and support.

Use case scenarios for 10-cent microcontrollers in personal projects versus commercial products.

Availability and pricing comparison between CH32V003 and PY32F002 from LCSC.

Development board options and their impact on ease of use for the CH32V003 and PY32F002.

Performance and real-world testing of the CH32V003 and PY32F002 microcontrollers.

Comparative analysis of the CH32V003 and PY32F002 based on functionality, software environment, and ease of coding.

Final thoughts on the suitability of CH32V003 and PY32F002 for different applications and projects.

Transcripts

play00:00

a little while back I made a video about

play00:03

this the 10-cent Pua py 32

play00:07

microcontroller in that video I

play00:09

mentioned that the py 32 wasn't the only

play00:12

Ultra cheap flash-based

play00:13

microcontroller but there's also the wch

play00:17

ch32

play00:19

v003 which also comes in around 10 cents

play00:22

and it seems to be far more popular many

play00:25

of you left comments on that video

play00:27

discussing the merits of the ch32

play00:30

and that got me wondering did I make the

play00:32

right choice when I bought 500 of the

play00:34

p32 for my latest

play00:36

project well there's really only one way

play00:39

to find

play00:41

out this is a development board for the

play00:43

ch32

play00:45

v003 which is the cheapest of the ch32 V

play00:49

series and it's the most comparable to

play00:51

the p32 f002 a that I talked about

play00:56

previously I'm going to put this through

play00:58

its paces and determine which of these

play01:00

you should use if you only have 10 cents

play01:03

and you ignore the cost of passives and

play01:05

the circuit board and everything else

play01:07

you need to get started let's get into

play01:10

it I'm Zach and you're watching Zack of

play01:12

all

play01:13

[Music]

play01:19

trades I'm going to get started by

play01:21

discussing the biggest and probably most

play01:24

controversial difference between the py

play01:26

32 and the

play01:28

ch32 the pro processor core specifically

play01:32

the differences between the risk 5 Core

play01:35

in the ch32 and the arm cortex m0 plus

play01:39

core in the

play01:41

p32 risk 5 which stands for reduced

play01:44

instruction set computer five is a free

play01:47

and open-source instruction set

play01:50

architecture for background an

play01:52

instruction set architecture defines how

play01:55

the processor should behave with respect

play01:56

to software by outlining the things like

play01:59

in instructions registers and memory

play02:03

handling binary code that is written for

play02:05

One processor should work on any

play02:07

processor that follows the exact same

play02:11

Isa now let's contrast this to the

play02:13

cortex m0 plus core the MZ plus is

play02:17

intellectual property from arm which is

play02:19

a for-profit company and it's more than

play02:22

just an Isa but it also includes things

play02:24

like Hardware models physical IP and

play02:27

stuff that gets you much closer to

play02:29

actually building the ship on Silicon

play02:31

you also are going to get software tools

play02:33

and simulation

play02:34

tools now when you buy a cortex part a

play02:37

fraction of what you spend goes back to

play02:39

arm in royalties okay I am assuming here

play02:42

that whoever makes the chip has properly

play02:44

licensed from arm there have been

play02:46

instances where foreign companies have

play02:48

stolen the IP while I can't be 100% sure

play02:52

that puya is licensing the devices

play02:54

correctly they do show up in Keel

play02:56

microvision which is a IDE that's

play02:58

released by arm

play03:00

it seems a little unlikely to me that

play03:02

arm would knowingly add microcontrollers

play03:04

to their software if they weren't

play03:06

properly licensing them so then what do

play03:08

the makers of risk 5 chips do for their

play03:11

Hardware Designs well most commonly it

play03:14

would seem that they develop their own

play03:15

proprietary implementations which is

play03:18

what wch has done here with the ch32 and

play03:21

their shinky core hope I'm pronouncing

play03:23

that right there are other open- source

play03:26

implementations including verilog

play03:28

descriptions and that's pretty cool in

play03:31

all honesty though I don't know that

play03:32

this matters for the majority of

play03:35

hobbyists we're not likely to be making

play03:37

our own silicon although that day is

play03:40

approaching you can Implement these

play03:42

verilog descriptions on fpgas but that's

play03:45

probably more of a learning exercise

play03:47

than something You' regularly

play03:49

do another point I'd like to make is

play03:52

that microcontrollers are far more than

play03:54

just their processor cores they also

play03:56

have memory peripherals power system

play03:59

systems clocks and so on and those can

play04:02

actually be more important than the core

play04:05

itself the arm versus risk 5 debate

play04:08

doesn't actually tell us anything about

play04:09

these peripherals and the majority of

play04:12

time these aren't going to be

play04:13

open the differences in peripherals also

play04:16

means that programming various risk five

play04:18

or arm parts even with the same core can

play04:21

be very difficult as there's not really

play04:24

any standardization of

play04:26

these finally I don't believe the

play04:29

underlying C core makes all that big of

play04:31

a difference from a programming

play04:32

perspective since most of us are

play04:34

probably writing our code in C or a

play04:37

higher level

play04:38

language if you want to multiply two

play04:40

numbers you're probably not worrying

play04:42

about loading values into registers

play04:45

finding the right instructions you're

play04:47

just going to type Cals a * B semicolon

play04:51

and move on with your life the compiler

play04:54

handles the rest and it's going to

play04:56

abstract away many of the differences in

play04:57

the underlying Hardware now don't get me

play05:00

wrong I'm a huge fan of Open Source I

play05:03

definitely prefer not to pay

play05:04

corporations for software that hasn't

play05:06

really changed functionality in decades

play05:08

looking at you Microsoft Office and I

play05:11

refuse subscription based

play05:13

software much of the software I use on a

play05:15

daily basis is open source and I

play05:18

contribute when I can I also believe

play05:20

risk 5 is an important development that

play05:22

will have a really positive impact on

play05:24

the industry but from what I've seen so

play05:27

far I don't believe that risk 5 microc

play05:29

controllers have a really substantial

play05:31

Edge over arm devices at least not yet

play05:35

for one the ch32 is different enough

play05:38

that you'll need different software and

play05:40

different programmers and that adds to

play05:42

the cost and it can have a fairly steep

play05:44

learning curve and despite not requiring

play05:47

royalties risk five parts don't seem

play05:50

cheaper at least not for the parts I'm

play05:52

comparing here but I'll get to cost in a

play05:55

second what I do think is awesome about

play05:57

risk 5 and one of the reasons I'm really

play05:59

excited about it is that it will allow

play06:01

companies researchers and even hobbyists

play06:04

to freely Implement processors where

play06:06

they probably wouldn't have otherwise

play06:08

bothered I foresee companies making more

play06:11

ic's smart as adding a processing core

play06:14

to a ADC an IMU or a radio whatever

play06:18

that'll no longer require that company

play06:20

to involve their lawyers and write

play06:22

contracts and pay fees just to license

play06:25

that Core Design the benefits for

play06:27

Academia will also be huge not just

play06:29

research purposes but also because

play06:31

students now have an actual open-source

play06:33

Isa to study when they're learning how

play06:36

processors

play06:37

operate I think there are also benefits

play06:39

on the 64-bit processor side for

play06:42

application processors as well as

play06:43

personal Computing but I'm not as

play06:45

familiar with that and it's outside the

play06:47

scope of this

play06:48

discussion that's all I'm going to say

play06:50

right now about core differences but at

play06:52

the end I'll bring this full circle and

play06:54

give you my thoughts when choosing a

play06:56

microcontroller or any other component

play06:58

for that matter

play07:00

cost is only one part of the broad

play07:02

picture ease of use availability support

play07:06

tool chains total bomb cost ease of

play07:09

assembly part Lifetime and so on are all

play07:12

things you need to consider so when

play07:15

might you actually want to use one of

play07:17

these 10-cent microcontrollers versus

play07:19

one of the more expensive

play07:20

options first I personally believe that

play07:23

these chips only make sense if you're

play07:25

using them on your own circuit boards if

play07:27

you're looking to just buy a development

play07:29

board for a one-off project then I

play07:31

couldn't recommend either of these for

play07:33

reference I got this development board

play07:36

as part of a larger package on Amazon it

play07:38

came with this a ch32 v203 development

play07:43

board a wch link e programmer and five

play07:48

each of the chips from both of these

play07:49

boards and this was all

play07:52

$27 I put a link down in the description

play07:54

if you're interested and I can attest

play07:56

that these work fine at least to the

play07:58

extent I've tested them

play08:00

now while I wouldn't say this is a

play08:01

terrible deal and there are certainly

play08:03

cheaper options especially if you go

play08:04

from overseas vendors there are lots of

play08:07

options from other more reputable

play08:09

companies in this price range and

play08:11

they're certainly easier to use and

play08:13

they're going to have more

play08:14

features the stm32 blue pill or the new

play08:18

cleos the

play08:20

esp32s any of the arduinos the Raspberry

play08:23

Pi Pico I think that these and really

play08:26

any of the popular development boards

play08:27

are going to be better choices

play08:30

so one use case for these 10-cent Parts

play08:33

could be to save money when you're

play08:34

building a product you're going to sell

play08:36

although honestly I'm not sure I'd feel

play08:38

that comfortable doing that either I

play08:40

would worry that one of these

play08:42

manufacturers might suddenly stop making

play08:44

these which would invalidate much of the

play08:46

non-recurring engineering You'

play08:48

done also if I opened up some product

play08:51

I'd bought especially something I

play08:53

expected to have a long life and I saw

play08:55

one of these Ultra sheep chips in there

play08:57

I'd be a little put off personally if I

play09:00

were making something I planned on

play09:01

selling I'd spend a little more money

play09:03

from a part from St or Texas Instruments

play09:06

or

play09:07

Renu one of the parts I could just buy

play09:09

from digy and be reasonably assured it'd

play09:12

be around for the next

play09:13

decade now where I do think these

play09:15

microcontrollers are really useful is

play09:17

for projects where you need a lot of

play09:19

microcontrollers that are doing pretty

play09:21

basic tasks this is what I'm doing with

play09:23

the p y32 in my tile backsplash

play09:27

project here I'm using the inter ADC on

play09:30

the py 32 to digitize a microphone

play09:32

signal and communicate the peak value

play09:35

back to a main processor I need about

play09:38

250 of these so for a personal project I

play09:42

just really can't afford to use anything

play09:43

more

play09:44

expensive check out the video on that

play09:46

project if you haven't And subscribe so

play09:48

you can be sure to catch the rest of

play09:50

it these types of projects things like

play09:53

making an analog sensor into a smart one

play09:55

doing at the sensor processing or event

play09:58

detection

play09:59

heck even making your own personal

play10:01

Computing cluster these are the cases

play10:04

where these Ultra cheap microcontrollers

play10:06

shine so I've called these both 10-cent

play10:10

microcontrollers but how accurate is

play10:12

that for comparison I'm only looking at

play10:15

the lowest spec cheapest Parts which are

play10:17

the ch32

play10:19

v003 and the py 32

play10:23

f002 and these prices are as of mid

play10:26

2024 on LCSC which I considered to be a

play10:30

reliable vendor you can buy the py 32

play10:32

for between 13.2 C and 17.5 cents if you

play10:36

buy only 5 and 8 cents to a smidge over

play10:40

11 cents if you buy 500 depending on the

play10:43

package the ch32 in comparison is on the

play10:47

order of 19 to 23.5 cents for five and

play10:51

12 to 14 1.2 cents for

play10:54

500 additionally as of right now you

play10:57

can't even order 500 of a single type of

play11:00

ch32 because there are only 415 sop 8s

play11:04

in stock and 100 qfm 20s for the py 32

play11:08

on the other hand all five options are

play11:11

in stock and the scarcest one has over

play11:15

4500 now I know that you can buy the

play11:17

ch32 on AliExpress from the official wch

play11:21

store in fact you can apparently get 50

play11:23

of the8 pin ch32 v003 chips for a single

play11:28

dollar shipped which is

play11:31

absurd but that's a onetime deal and you

play11:34

don't have much control over

play11:35

quantity I am also personally far less

play11:38

comfortable ordering from AliExpress but

play11:41

you could feel differently about that so

play11:43

from a cost and availability perspective

play11:45

on bare chips I have to give the

play11:47

advantage to the py

play11:49

32 if you're looking for development

play11:51

boards though then the exact opposite is

play11:53

true there is this board for the py 32

play11:57

f003 on LCS CX right now it costs about

play12:01

$14.5 which is a bit high for what

play12:03

you're getting and I've noticed that the

play12:05

price fluctuates

play12:07

considerably there are a couple other

play12:09

options for the p32 but they have no

play12:11

reviews and probably no

play12:13

documentation the C32 though like I said

play12:17

I got this on Amazon delivered in two

play12:20

days with the spare chips it was a

play12:22

little pricey at $27 but very easy to

play12:25

order check out the description for the

play12:27

link there's also plenty of other

play12:30

cheaper options for the ch32

play12:32

particularly from overseas just Googling

play12:34

ch32 v003 will turn up lots of options

play12:39

so for development boards I've got to

play12:41

give the edge to the

play12:42

ch32 taking a look at the data sheets

play12:45

you'll find that there's really no clear

play12:46

winner as the p32 f002 and the ch32 v003

play12:52

trade blows in different areas now

play12:55

allegedly the py 32 f2a

play12:59

uses the same die as some of the higher

play13:01

end parts and you can unlock additional

play13:04

features if you know what you're doing

play13:06

but that's not guaranteed that might not

play13:08

always be true so for this comparison

play13:11

I'm sticking strictly to what is

play13:13

advertised to start the ch32 can run up

play13:16

to 48 MHz and it has a PLL that can make

play13:19

that frequency from the 24 MHz internal

play13:22

oscillator the py 32 though runs at half

play13:25

that 24 MHz it has no PLL

play13:29

the p32 does have the edge for Ram and

play13:31

Flash with 3 kilobytes of RAM and 20

play13:34

kilobytes of flash whereas the ch32 has

play13:37

2 kiloby of RAM and 16 kiloby of flash

play13:41

both parts have one Advanced timer and

play13:43

one basic timer but the p32 has an

play13:46

additional low power timer both have

play13:49

adcs however the py 32s is 12 bits and

play13:52

the CH 32s is only 10 if you're sampling

play13:56

that data really quickly though you

play13:57

don't want to load up the process

play13:59

then you're going to find the dma on the

play14:01

ch32 very useful but you don't get on

play14:03

the

play14:04

p32 the ch32 also has a built-in op amp

play14:09

which if you need it could reduce your

play14:10

build of materials in comparison with

play14:12

the

play14:13

p32 for connectivity they both have one

play14:16

uart one spy and one i2c but there's a

play14:20

caveat for the

play14:21

ch32 the Spy is only broken out on the

play14:24

20 pin packages there's no spy on the 16

play14:27

and eight pin options

play14:29

compare that to the py 32 where you get

play14:32

the option for all three regardless of

play14:34

package if you have an application in

play14:36

mind though you should probably check

play14:38

out the multiplexing on those really

play14:39

small packages as some of those

play14:41

functions

play14:42

overlap other than that these two parts

play14:45

are really similar they can both operate

play14:47

at 5 volts they both have comparable

play14:49

package options and number of IO and

play14:52

they have similar low power modes as you

play14:54

can probably see it is hard to declare

play14:57

one of these better than the other

play14:58

without knowing your exact

play15:00

application on one hand the ch32 is

play15:03

faster and has dma and that built-in op

play15:05

amp but the py 32 has more Flash and RAM

play15:09

and a higher resolution

play15:10

ADC the data sheets one thing but how

play15:13

did these chips actually perform in the

play15:15

real world and how easy are they to use

play15:18

for the py 32 go back and check out my

play15:21

previous video where I walked through

play15:23

setting up the IDE and then did two

play15:25

coding examples now the p32 has

play15:29

pretty much no information online and

play15:31

there really aren't any tutorials which

play15:33

is definitely a drawback so in the

play15:35

previous video I went into quite a bit

play15:37

of detail on how to use them there is

play15:39

much more information for the ch32

play15:41

though so I'm not going to walk through

play15:43

this step by step like I did before what

play15:46

I am going to do is replicate the two

play15:48

test codes I did in the last video first

play15:50

I'm going to Blink an LED using a timer

play15:52

and interrupts and then secondly I'm

play15:55

going to read an analog voltage with the

play15:57

internal ADC and report it to computer

play15:59

over

play16:00

serial I'll then compare the experience

play16:02

on the ch32 with that of the

play16:05

p32 for ID I'm going to be using Mound

play16:08

River this is what is recommended by wch

play16:12

which is why I'm choosing it similar to

play16:13

what I did for the

play16:14

p32 there are other IDE options probably

play16:18

better options there's even support for

play16:20

the Arduino IDE so don't be too scared

play16:22

away by this mound river is Eclipse

play16:25

based so it's going to feel pretty

play16:27

familiar if you're coming from some

play16:28

something like the stm32 cube

play16:32

IDE as mentioned the boards I'm testing

play16:35

this with came from Amazon and included

play16:37

two development boards one for the ch32

play16:40

v003 and one for the

play16:43

v203 as well as 10 bear chips and the

play16:46

wch link e which is this comically bulky

play16:50

USB programmer that you can't actually

play16:52

push the buttons on without removing the

play16:54

case there's also a GitHub repository

play16:56

I've linked that has lots of information

play16:58

on this ship and this board things like

play17:01

the schematics example code some how-to

play17:04

PDFs I recommend you poke through that

play17:06

before you get started when you open

play17:08

Mound River and go to create a project

play17:10

you basically just need to provide a

play17:12

name and select the chip you're using

play17:14

click okay and that's it all the start

play17:17

code and the how drivers are there and

play17:19

ready to use the start code sends the

play17:21

system clock rate and the chip ID over

play17:24

uart as well as has some uart Echo

play17:27

functionality without making any changes

play17:29

to the start code I compiled and flashed

play17:31

it just to verify that this at least

play17:33

worked I used the serial adapter built

play17:36

into the link e as well as MOA xterm on

play17:38

a PC all I had to do was connect 3.3

play17:42

volts from the debugger to VCC on the

play17:44

board ground to ground s swdi to pd1 and

play17:49

RX to pd5 this would have worked great

play17:53

except my link e firmware was ever so

play17:55

slightly out of date so M River refused

play17:57

to use it and it forced me to update it

play17:59

which I tried to do itself halfway

play18:02

through the update process though the

play18:04

link e disconnected from my computer and

play18:07

didn't come back now those of you that

play18:09

deal with these things regularly know

play18:11

that this can be a bad situation a

play18:13

little searching though led me to the

play18:15

wch link utility which is available

play18:18

straight from WC's website this luckily

play18:21

recognized the link e and I was able to

play18:23

update it without much trouble back over

play18:26

in Mound River the program now flashed

play18:28

directly and the serial communication to

play18:31

my PC worked as it

play18:32

should I then got started modifying the

play18:35

code to Blink an LED with a timer this

play18:38

is pretty straightforward and honestly

play18:40

pretty similar to the p32 or any other

play18:42

arm part you configure the timer start

play18:46

it in the appropriate mode configure the

play18:48

LED GPO pin write an interrupt Handler

play18:52

where the pin is actually flipped and

play18:54

then you call the initialization

play18:55

functions from the main function and

play18:57

enter an infinite Loop

play18:59

interrupts will do the

play19:00

rest interestingly the ch32 development

play19:04

board doesn't actually connect the led

play19:06

to a pin unlike what you would usually

play19:09

see so you get to choose where it goes

play19:12

the downside though is that this does

play19:14

require a wire on the development board

play19:16

which might not be desirable for your

play19:18

final application I did have one issue

play19:21

and a couple of

play19:22

complaints the issue I ran into is in

play19:25

regards to attributes on the interrupt

play19:27

Handler function prototype

play19:29

I'm not going to go into great detail

play19:31

here as I wouldn't say that I fully

play19:33

understand it myself but the Crux is

play19:35

that if you create an interrupt Handler

play19:38

and the wch interrupt fast attribute is

play19:41

applied to the other interrupt handlers

play19:43

then you should go ahead and apply it to

play19:44

the one you create as well I didn't and

play19:48

my initial code ended up in the hard

play19:49

fault

play19:50

Handler luckily since this

play19:53

microcontroller is fairly widely used I

play19:56

actually found a discussion and a

play19:57

solution for this issue online line my

play20:00

complaints are in regards to the

play20:02

documentation the data sheet the

play20:04

reference manual there's a core manual

play20:06

and a bunch of other how-to guides

play20:08

they're really well written and they're

play20:10

written in English unlike what you get

play20:11

for the

play20:13

p32 but I could not find any

play20:15

documentation for the hardware drivers

play20:17

despite the fact that they're used by

play20:19

default in Mound River now to be fair

play20:23

poya also does not have documentation

play20:25

for the drivers on the p32 but those

play20:27

drivers are BAS basically just copied

play20:29

from STM 32s so st's 2000ish page Hal

play20:34

manual is directly

play20:36

applicable for the ch32 I basically

play20:39

didn't have any guidance other than the

play20:41

reference code and reading through the

play20:43

drivers in the

play20:45

IDE now I know roughly what I'm doing

play20:48

and the drivers behave pretty similarly

play20:50

to the arm devices they mostly just

play20:52

differ in syntax so I was able to

play20:54

stumble through this by just using the

play20:56

ide's autocomplete functionality

play20:59

and kind of just guessing what the

play21:00

function should be but still it would

play21:03

have been really nice to have a manual

play21:05

if anyone knows that one exists please

play21:07

let me know now this brings me to

play21:09

another minor complaint this is

play21:12

regarding the reference code the

play21:14

reference code provided on GitHub is

play21:16

quite complete it covers every

play21:17

peripheral but I found that it only

play21:19

covers more complicated use cases take

play21:23

the timers for instance there's an

play21:25

example code for dma for encoder

play21:27

counting for output compare one pulse

play21:30

modee Etc but there's not an example

play21:33

that just covers setting up a timer to

play21:35

generate an interrupt the ADC is another

play21:37

good example there is no code that just

play21:39

covers a single software start

play21:42

conversion which is probably what most

play21:44

beginners the ones who are reading the

play21:45

example code anyway are trying to do you

play21:49

can certainly piece together what you

play21:50

need from some of the more complicated

play21:52

examples but I found this a bit odd

play21:55

regardless I worked through this Blinky

play21:57

example reasonably quickly and I got the

play22:00

board to Blink its LED 500 milliseconds

play22:03

on 500 millisecs off without much

play22:05

trouble this was certainly faster than

play22:08

getting the py 32 running even when you

play22:10

take into account updating the link e on

play22:13

to the more complicated example reading

play22:15

a voltage with the ADC and sending it

play22:18

over serial to a computer setting up the

play22:21

uart here couldn't have been easier

play22:23

literally because it's already done for

play22:25

you in the start code there is a debug

play22:28

file

play22:29

included you can go through and check

play22:31

out the exact functionality but one

play22:33

thing it does is redirects print F to

play22:36

ur1 all you need to do is know the pins

play22:39

pd5 for TX and pd6 for RX hook them up

play22:43

to the link e appropriately and then

play22:45

print F just

play22:46

works compare this to the p32 where I

play22:49

still haven't gotten print F to redirect

play22:51

correctly I'm compiling messages and

play22:54

then sending them over to Art the manual

play22:56

way the other main thing that needs to

play22:58

be done here is configuring the ADC this

play23:01

took a little bit of playing around

play23:03

because of the aformentioned lack of

play23:05

documentation on the how drivers pretty

play23:07

simple stuff like should this field be

play23:10

zero indexed or one indexed and how do I

play23:12

do a single conversion since all the

play23:14

example codes or multiple or injected

play23:17

conversions overall though I would say

play23:19

that this example took me a similar

play23:21

amount of time to what it did on the p32

play23:24

with my lack of familiarity with the

play23:26

drivers being offset by the fact that

play23:28

the uart was already set

play23:30

up so here's the circuit setup I've just

play23:33

run VCC to one side of a potentiometer

play23:36

ground to the other side and the center

play23:38

tap of the pot to pd3 which is ADC

play23:41

Channel 4 on this chip this makes an

play23:44

adjustable voltage divider and you can

play23:46

see here that as I rotate the pot the

play23:48

ADC values respond logically I'll be at

play23:51

only to 1023 as this is only a 10 bit

play23:54

ADC the ADC noise seems quite small only

play23:58

an LSB or so at 43 cycle sampling time

play24:02

and I ran this for many hours and I

play24:04

didn't observe any drift so now that

play24:06

I've had the chance to test out both the

play24:08

p32 and the ch32 including their

play24:11

functionality native software

play24:13

environment and ease of writing and

play24:14

flashing code which chip is the

play24:17

winner well I hate to reiterate what

play24:20

I've already said but it really does

play24:22

depend on what your final application is

play24:24

for this chip as they both have pros and

play24:26

cons and they could make break a

play24:28

particular

play24:30

project but if they both have the

play24:32

features you need then well I have to

play24:35

give the edge to the

play24:36

ch32 it comes down to four things first

play24:40

when you download mountain river and you

play24:42

select the ch32

play24:44

V3 it pretty much just works there's no

play24:47

messing around with configuration no

play24:49

trying to load the right Hardware

play24:50

libraries really nothing other than

play24:52

needing to update the link e after that

play24:55

I literally hooked up the debug probe

play24:58

compil

play24:59

loaded the start code and that was it it

play25:01

just

play25:02

worked second and you might not

play25:05

personally care about this but risk 5 is

play25:08

kind of cool right now and by using the

play25:11

ch32 you're helping to support that

play25:14

movement third I think I have to give

play25:17

the hardware Edge to the

play25:19

ch32 it runs at twice the speed it has a

play25:23

dma controller and I feel like that's

play25:25

probably a little more useful than what

play25:27

the py 32 has has which is additional

play25:29

Flash and RAM the higher resolution ADC

play25:32

and an additional timer you could debate

play25:34

this point though so take that with a

play25:36

grain of

play25:37

salt and finally there's a lot of online

play25:40

help for the ch32 not necessarily

play25:43

directly from wch but in online

play25:46

discussion and even a lot of

play25:48

tutorials now the p32 is very very

play25:51

similar to the stm32 so stm's

play25:54

documentation even for stuff like the

play25:56

how drivers is very use use ful but

play25:59

there's essentially no online help

play26:01

specifically for the

play26:03

p32 that said I did find the lack of

play26:05

driver documentation on the ch32 to be

play26:08

quite

play26:09

frustrating so did I make the wrong

play26:11

choice when I bought these 500 p32 chips

play26:14

for my tile backsplash

play26:16

project I don't think so and it all

play26:19

comes down to

play26:20

availability remember when I said that

play26:22

for the ch32

play26:24

v003 there were only 415 of one package

play26:28

and 100 of another package in stock well

play26:31

I wrote that a couple days ago and

play26:33

before filming this I went back and

play26:34

checked again now there is not a single

play26:37

ch32 v003 in stock at

play26:40

LCSC and that's the problem if you want

play26:43

10 50 maybe even 100 CH 32s then sure

play26:48

you can probably order them on

play26:49

AliExpress you'll probably get what you

play26:51

need but if you need a whole spool of

play26:53

these even just 500 of them then you're

play26:56

out of look with the p32 though I've

play26:59

never had to worry about stock plus it's

play27:02

not like one of these existing negates

play27:05

the usefulness of the other one you can

play27:07

have and use both of them I think that

play27:09

they're both fantastically useful

play27:11

microcontrollers they're not all that

play27:12

different to program they're both an

play27:14

insane value and now that I've got an

play27:17

experience with both of them I'm going

play27:19

to keep them both in mind for future

play27:21

projects that's all I've got today in

play27:23

the next videos I'll be getting back to

play27:25

some of the projects so please like

play27:27

subscribe

play27:28

and check those out thanks for watching

Rate This

5.0 / 5 (0 votes)

関連タグ
MicrocontrollerCH32PY32ComparisonEmbedded SystemsHobbyistDeveloperOpen SourceHardware
英語で要約が必要ですか?