moving from esp32 to ch32v003 --- advice for a hobbyist - Page 1
Forum section: electronics / beginners

author: osmax_br
author_rank: Regular Contributor
timestamp: April 01, 2025, 10:27:55 am
content: Hi eevblog peopleI was thinking about expiramenting with new MCUs other than ESPsI am thinking about pulling the trigger on ch32v003 kit (evaluation board+wch link+ 5x ch32v003)before buying it I want to ask some questions for the mcu people (I'm not professional nor intending to use it in a professional job project, I'm just a hobbiest trying to get things seriously)- how much time should I consider for gaining the ability to comfortably work with the mcu  (the learning curve expectations)-is there any resources for learning it (other than the datasheet of course) , something on youtube, blog or a book etc....- how much library support is available ( eg, lvgl , ssd1306 , ir etc...)- if I invested time and got comfortable with this exact mcu architecture (wch products) will it be easy to switch to smth like stm in the future, or do I need to start from zero because of different registers , functions etc....- is there any support for rtos system, free rtos or zephyr os?- most important question : is there a dark theme in their IDE ? I've worked with esp32 for the past 5 years , I do a mix between free rtos ESP-IDF functions and some Arduino frame wrap , did somewhat complex projects (for a hobbiest of course)Thanks in advanceand sorry, these might be basic questions, but didn't find much info online

author: ahsrabrifat
author_rank: Regular Contributor
timestamp: April 01, 2025, 11:29:31 am
content: CH32V003 related tutorials are still rare. Bot as available as STM32 or ESP32. However, the following sources may help.https://github.com/karasevia/finik-v003https://github.com/openwch/ch32v003

author: brucehoult
author_rank: Super Contributor
timestamp: April 01, 2025, 11:30:02 am
content: Note that recent ESP32 e.g. ESP32-C3, ESP32-C6 ... and they say all future ESP32 ... are RISC-V ISA just like the CH32V -- at least as far as the instruction set goes.The '003 is a little bit special in being only RV32EC, which means is has only 16 registers instead of the usual 32, doesn't have multiply and divide or atomic instructions.FreeRTOS and Zephyr support CH32V003, but bear in mind that it's a very small chip with just 2k RAM and 16k flash, so an FTOS can exhaust both very quickly! For example the default thread stack space in Zephyr is 2k! So you need to set that down. Way down. I think FreeRTOS has a 200 byte default.But in general with such a small chip you're better off writing bare metal.WCH of course has other much larger family members with more RAM, Flash, MHz, peripherals ... the '003 is more of an AVR or PIC or 8051 replacement than an ESP32 or STM32 replacement.There is a TON of 3rd party resources. Just Google. It's a very popular chip.There is a getting started video by our very own host:Moving to or from STM32 should be very easy as WCH copied the ST Micro peripherals. If you can't find enough information or examples for a CH32V peripheral then just look at the docs and examples for STM32. We had an example the other day of WCH using a different name than STM for one register, but it turned out to be the same offset and values.Charles Lohr has a good reference site for the CH32 series, with his own hardware defines, and examples.https://github.com/cnlohr/ch32funHe also has some fun (very advanced!) projects:Another cool project:And a commercial 1 euro kit retro-PC from Olimex:> how much library support is available ( eg, lvgl , ssd1306 , ir etc...)I don't know what those are :-(> most important question : is there a dark theme in their IDE ?What's an IDE?Nothing forces you to use anything more than emacs/vim and gcc.There is support in PlatformIO (VSCode based). Of course that has dark mode.Yeah they have their own Eclipse-based IDE. You don't have to use it.> but didn't find much info onlineNo idea why.

author: osmax_br
author_rank: Regular Contributor
timestamp: April 01, 2025, 12:00:40 pm
content: Quote from: brucehoult on April 01, 2025, 11:30:02 amThanks for the reply !I don't want to use v003 as a replacement for the esp32 , I just want to use it as a secondary mcu in addition to the esp32Eg: I am making a gui using an LCD and esp32 , I am also connecting 40+ 7seg displays , sure the esp can handle such a thing using shift registers , but I want a more modular approach where you can connect and disconnect or add new 7seg without re programming the esp , sure you can get all of that running on an esp32 with enough knowledge, imagination and time , but I have neither of thoseSo I want the v003 as a driver for the displays which uese i2c to communicate with my esp32This is one of the many ideas that I have , but in general I want to use it as a second mcuI watched a lot of chlohr videos , they are probably the reason why I wanted to start using thoseLvgl : light and versatile graphics library, it is a very popular library for designing UI for embedded systems , as their website says "it is used by a lot of companies like Xiaomi to design their commercial products" , I didn't fact check that , but the library is the best at its kind , very well documented , can work with any display driver with little tweaksssd1306: the library used to drive these small OLED 0.96" displaysThey are supported but the AI says they are buggy , so I asked here to see whether it's really very buggy or it is just AI nonsenseQuoteYou can find a lot of technical info , GitHub projects of course , but I didn't find advice like the one you wrote above (Thank you) ,you cant get the kind of advice you get in the forums here from AI or random internet pages (especially on something like wch products , which seems to be considered for more professional users) , also just reading professional code on github without some explanation is a bit hard for someone like me

author: brucehoult
author_rank: Super Contributor
timestamp: April 01, 2025, 12:54:10 pm
content: heh. A 16 pin CH32V003 is about half the price of a '595 shift register -- but could easily emulate one. Or do a lot more.Even just replacing a 7400 quad NAND gate, the CH32V003 is cheaper and can do the job with a tiny tiny program as long as you don't need tooooo low a propagation delay. 8 input pins to 4 NAND gates ... you could just have a 256 byte lookup table, copied to SRAM on startup, with the 4 bit output for the 4 gates for every possible set of input values. How fast can you loop on "read PortC, load byte from RAM, write PortD"?Sadly, you need the 20 pin version to get a port with all 8 input bits present ... the 16 pin SOP-16 CH32V003A4M6 package for whatever reason has PortC bits 0,1,2,3,4,6,7 but not 5. But both 20 pin packages have the whole PortC.Code:li a0, 0x40011000 # GPIOC base addressli a1, 0x40011400 # GPIOD base addressli a2, NAND_tableloop:lw a3, 0x08(a0) # Read PortC INDR (input data register)add a3, a3, a2lbu a3, (a3) # look up NAND output for all four gatessw a3, 0x0C(a1) # Write to PortD OUTDR (output data register)j loopIf you had the NAND function lookup table in the first 2k of Flash then you drop the `add` and just put an offset on the `lbu` Or .. you can actually alias EITHER flash or SRAM at address 0, right?

author: osmax_br
author_rank: Regular Contributor
timestamp: April 01, 2025, 12:57:57 pm
content: Quote from: brucehoult on April 01, 2025, 12:54:10 pmlol I didn't think about thatall I was thinking about is to use 595 shift registers in addition to the v003but now I have different plansthanks

author: John Celo
author_rank: Regular Contributor
timestamp: April 01, 2025, 04:32:21 pm
content: There are 595 shift registers on LCSC for as little as 3-4cents a piece.Whilst ch32v003 are 16-20cents a piece (on LCSC) depending on the package. So atleast 5 times as expensive.And 50 times as expensive if you consider that you have to program/flash each one.74HC00D quad nand gates are as little 6-8cents a piece, 8cents for a texas instruments one.If you need a shift register or a logic IC, use it. Inverters, hex schmitt triggers 74hc14, etc, all 6-8cents each at hobbyist 50unit quantities.Most jellybean logic ICs are extremely cheap. The more commonly used it is, the cheaper it is.If you buy parts from Mouser etc, you get very skewed, order-of-magnitude-off perception of pricing where you can reason yourself in usingMCUs where a simple logic IC is actually exactly what's necessary.You can always just buy an MCU with more pins - such as GD32E230C8T6 (LQFP-48, arm cortex m0 72mhz, 36cents at 30unit qty), ie. STM32F0 clone. WCH mcus need special SWD probe - WCH-link (it is not expensive though, like 5 bucks).I'm still a beginner and I'm still learning... but I have a bit of an obsession with creating as much value/functionality with the least amount of cost and using the very "cheapest" MCU is not necessarily how you get there I think.Adding extra MCUs to the design - that you have to write code for, program and flash seperately - using different methods etc, just adds complexity and cost (in terms of your time which has value)

author: brucehoult
author_rank: Super Contributor
timestamp: April 02, 2025, 01:22:45 am
content: Quote from: John Celo on April 01, 2025, 04:32:21 pmI have never seen prices anything like this.But if the prices are anywhere near close then the added flexibility of a microcontroller is a big advantage. If you are soldering by hand then the extra time to program it is minor. And the benefit of not having to have stocks of many different chips also.If you want to made some physically large object with LEDs or servos or anything like that many cm apart then communication via SPI or I2C or similar is very useful.WCH have a new chip CH570 which they are giving free samples and dev boards today. It is 10c and is like a CH32V003 but with USB and also a 2.4 GHz radio, and also 16k RAM and 256k flash. Use voucher code :XJI0YRGF5ZXY. They don't say what the radio supports but I'd assume something similar to the old nRF24L01 chips from a decade ago.https://www.aliexpress.com/item/1005008743123631.htmlhttps://www.youtube.com/shorts/KIz0jpzJiIohttps://www.wch-ic.com/downloads/CH572DS1_PDF.html

author: John Celo
author_rank: Regular Contributor
timestamp: April 02, 2025, 04:01:35 am
content: QuoteStandard IC pricing in asia, from LCSC, etc. See pic attached.Seeing those py32f002 / ch32v003 for 10/20 cents a piece, and going like - oh wow, I could use these as "universal" logic ICs is a common first gut reaction. That first jolt of excitement.It's one of those "great" ideas, that stop being "great" once you actually sit down and think about it for a solid minute or two.1. What if you don't want to solder and flash by hand anymore? PCBA with preflashed mcus is not a cheap standard option.2. Going to put swd/swc/boot/nrst everywhere and flash every arm/riscv mcu where a logic IC should be?3. What if somebody needs to replace old defective part?Now they have to buy a specific MCU (if it's still in stock anywhere) with specific pinout and program it with code they don't have, with whatever nonstandard pinout you use. Buy whatever specific programmer the MCU uses, etc.QuoteBuying MCUs and then flashing them with jellybean logic IC code isn't flexibility, it's liability, a dependency on one vendor and bringing unnecessary complexity into a design where none should be.I'm sure there are some corner cases where this makes sense, but you'd better think twice before doing "weird shit" like this.Collecting a parts bin with jellybean parts, commonly used 74 series and logic ICs is a rite of passage that a beginner is going to have to acquit themselves with sooner or later.If you're ordering a PCB design as a beginner, you're highly likely going to have to order all sorts of parts you don't have anyway.*saying this as a complete beginner

author: brucehoult
author_rank: Super Contributor
timestamp: April 02, 2025, 04:19:47 am
content: Geez don't be such a grinch.I was building things using 7400-series, 555, 741 in the late 70s. I design and build things only for my own amusement, not for anyone else or for mass-production or sale. There will never be anyone else who will ever be confused how to repair or reprogram them.Of course it would be silly to use a '003 to replace a quad NAND gate, but it's interesting to think what the performance would be.And what if you want a single NAND gate, a single SR flip-flop, a single OR gate? With off the shelf parts you're going to need three partially-used chips, where a single microcontroller can do it with ease (at least up to a few MHz). Or an FPGA, but they start at a much higher price.You're probably against people using FPGAs too.And don't forget your 10c microcontroller now gets you USB FS and 2.4 GHz GFSK packet radio.

author: osmax_br
author_rank: Regular Contributor
timestamp: April 02, 2025, 09:00:20 am
content: I'm doing this only for funsure if I'm mass manufacturing I'd use shift registersbut I like doing weird things  , putting 2 mcu in the same project seems weird enough for meand I want to find things that I can do cheaply with v003so I asked the question above about how hard is it to switch from esp32 to v003 (not replacement but rather learning how to use v003)https://www.eevblog.com/forum/projects/unconventional-ways-to-display-number-analog-clocks/

author: brucehoult
author_rank: Super Contributor
timestamp: April 02, 2025, 09:21:21 am
content: Quote from: osmax_br on April 02, 2025, 09:00:20 amI don't want to get sucked into that other thread, but did you see this?https://www.instructables.com/Hybrid-Clock-Mechanical-Fusion-of-Digital-and-Anal/

author: cunningfellow
author_rank: Regular Contributor
timestamp: April 02, 2025, 10:24:40 pm
content: That is a rather unfortunate length of string cut off in the URL

author: brucehoult
author_rank: Super Contributor
timestamp: April 03, 2025, 12:15:54 am
content: Quote from: cunningfellow on April 02, 2025, 10:24:40 pm50 characters is as logical a number as any. But IANAL.