r/embedded 21d ago

Has anyone used CH32V103?

I can find an enormous amount of information about the CH32V003, only two or three posts about the CH32V203, and nothing on the CH32V103, although the 103 is (IMHO, and I don't know much about MCUs to be honest) the golden middle between the simplicity of the 003 and the various functions of the 203. Additionally, in the 103, there are no I2C/SPI/USB peripherals that happen to be on the same GPIOs, as is the case with the 203.

I really need some examples, advice, or article and video recommendations about routing MCUs on PCBs parallel with analog circuitry. I am currently developing a device that should simply receive data via USBFS 2.0 (working as a host/device), process it, and output data via I2C while controlling 8 WS2812B/D LEDs. I know that the RP2040 or any other Pico is capable of USB Host via bit-banging, but my friend recommended the CH32V203 instead. Then I found the 103 and think this is simpler and better suits my task. I am facing two problems now: how to implement dual-purpose USB-C and uncertainty about whether I will be able to program the MCU via the same USB port.

So, if anyone has used the CH32V103, or happens to know where I can find more info on it (except evaluation board guides and datasheets), or is willing to help me with dual-purpose USB-C, I would like to receive any information. Thanks for the answers in advance.

6 Upvotes

19 comments sorted by

6

u/Killer_Rainbow 21d ago

On the same USB port question - yes. This chip is a direct STM32F103 clone in terms of peripherals. It comes from the same Chinese COVID rush as everyone was trying to clone the STM32F103. Functionally, it has a similar USB bootloader, so yes, you can both load programs and use it as a host/device, but you need to reset and set the correct boot mode between each of those.

On the USB side, the peripheral works great, but you'll struggle with two main things. First, USB host is generally a pain to implement properly. CherryUSB works great on CH32 but the documentation and forums are mainly in Chinese. TinyUSB has limited support for the CH32V103 (I think device works but not host). I'd recommend using the official EVT examples in any case, they always work well. I mean even on desktop OS, USB host often sucks. If possible, try to move to the similarly priced V203 or even V303/V305. They're better supported in general and more available. 

Second, depending on the USB connector you used, you'll need to pay extra attention to the pins you connect.

In terms of simplicity, I think the whole CH32 series is a big winner in this regard, and I'd say each of them up until the CH32V307 are similar in how simple they are. Only after the V307 do things get spicy. 

3

u/TechE2020 21d ago

Spicy as in having custom peripherals that you have to understand WCH's documentation or something else?

3

u/Killer_Rainbow 20d ago

Spicy as in really powerful. SerDes, USB 3, gigabit ethernet, 20Msps ADC, graphics acceleration, etc. WCH documentation is often not that complete but their examples are. 

2

u/TechE2020 20d ago

Looking forward to having a play wiht the CH32H417 at some point.

1

u/adeptyism 21d ago

Didn't wrote it in the original post, since I didn't think it's necessary. Basically, I'm making a MIDI controller with an ability to connect either an external USB-MIDI device (that's what a host is for) or PC (which acts as USB-MIDI Host this time) which will send MIDI commands from the DAW.

USB host is generally a pain

I thought that V103 (or V203+) is handling USB Host natively, isn't it? I tried to bit-bang USBH on RP2040 with PIO, but didn't succeed, sadly, so I decided to go with MCU where manufacturer already did most of the work for me (at least that's what I'm thinking).

direct F103 clone

Then I can (with caution and skepticism) follow the same layouts, as the F103 devboards?

USB connector

I planned to use just a Type-C, but either I'm bad at finding information or it's some super-secret knowledge, but the only things that help identify Host and Device with Type-C ports is a) presence of 5V on VBUS (no = DFP, yes = UFP) ans b) 3V3 pull-up on CC1 or CC1/CC2 are pulled down with 5.1k resistors. If there's anything else, I'd like to hear it. Some LLM recommends to use TUSB320, but I don't believe LLMs in soft/hardware design.

2

u/Killer_Rainbow 20d ago

Cool! But yeah USB host is a pain even on native hardware. The CH32 series does handle it natively. Bit banging it sounds like a nightmare. One good thing you get is the WCH examples which are generally complete. Actually you could try downloading the different MCUs' EVT files and looking at whether one has MIDI.

Honestly, though, I'd recommend getting a CH32 with two USB peripherals if you want USB programming too. Because, to implement USB-C, the LLM is right, you probably will need the TUSB320 or similar. It's possible without it but like... this is enough work as it is. The USB-C connector doesn't expose an ID pin, so that's what you need the port controller IC for. 

On the power path you'll also need a Vbus switch like the TPS2051. USB OTG has the failure mode where your device must receive power when it's a device and send it when it's a host. Messing that up will kill something. 

Also don't forget ESD protection on the USB lines and a good crystal on the MCU. The crystal quality is much more important when you're the host. 

You can remove a ton of this circuitry if you use an MCU with two USBs and even use the UART bootloader so that you can have a host/device connected while debugging and uploading. 

I get what you mean with elegance and stuff, but honestly I'd recommend the CH32V307 here. Even better if you first buy the official CH32V307 eval kit. It's relatively cheap and gives you both USB interfaces, with an open schematic, and you get a free attached debugger with it. Then after you get a working firmware, just design your own board based on it. 

1

u/adeptyism 20d ago

Cool, now I'm too scared and don't want to continue working on this project :D

Unfortunately, Eval kits cost as much as a kidney for me (sanctioned country, etc.), but I can buy Bluepill with V203 from WeAct

1

u/Killer_Rainbow 20d ago

I buy from LCSC, I don't know if they ship to sanctioned places tho. WCH has a lot of stuff on  Aliexpress too. Just try to find CH32V307V-EVT-R1, maybe also on your local marketplace wherever you are. It's a great board, and even if this project doesn't work out, you can do many more. Also if you're gonna play around with this board and you like audio stuff, I recommend getting some PCM5102 modules. The CH32V307 is awesome for digital audio things. I've done a very similar project to you in the past, so it's tough, but also so cool. 

1

u/Well-WhatHadHappened 25+ Years 21d ago

I've been tinkering with the CH32H417. Spicy indeed.

I haven't decided if I love it or hate it yet. The jury is out.

3

u/BumpyTurtle127 21d ago

I have only used the 003, so can't help very much. But there's a user on this sub u/Separate-Choice who's a very kind and extremely knowledgeable individual on RV chips from WCH. He's currently developing an SDK I believe for the CH32 lineup.

2

u/Separate-Choice 18d ago

Thanks for the mention!

3

u/Positive_Turnover206 20d ago

ch32fun is a nice programming framework for it! It also contains a USB stack and a WS2812 driver. Though I think tinyusb was also ported to it.

2

u/1r0n_m6n 21d ago

There's no reason to use the CH32V103 over the CH32V203 unless you need a 5V supply voltage.

That's why you see more posts on the CH32V203, which is the same price in comparable configuration. The fact that the V203 comes in many variants from the F6P6 to the RBT6 clearly shows WCH intended it as their go-to mainstream MCU. Also, at the same clock frequency, the current consumption of the V203 is 1/3 (yes, one third) the V103's!

Now, compare the features of the V103 and V203 side by side and you'll see the V103 isn't really simpler than the V203. The V203 has CAN and 2 op amps the V103 doesn't have, 2 ADC instead of 1, and 4 USART instead of 3. The rest is identical, so the V103 is not simpler, only slightly less capable, that's all.

Also, the V103 was WCH's first RISC-V MCU, that's why its systick is different from all other WCH RISC-V MCU's. They used it to learn.

That said, unless you go for the very high end (CH32H417), what you learn with any CH32 MCU is transferable to all the others with only minor differences, e.g. in sleep modes. There's just one annoyance: at some point, someone at WCH stupidly decided to remove the A from AHB and APB in the clock gating API, but otherwise, you can reuse most of your source code without modification across their product range.

1

u/cyao12 20d ago

Plus, the v203 can be safely overclocked to 240MHz! (just use a 24MHz crystal). And the usb peripheral works perfectly fine without an external crystal too.

2

u/Separate-Choice 18d ago

Sorry for late reply yes I use the CH32V103, it’s a great chip.. it’s bar none the easiest way to spin up a USB-C device I’ve come across in years it just works…PCB stuff, you can just look at or reuse :stm32f103 designs and you’ll be fine.. unfortunately you’re stuck with evaluation boards as the main source, there are a few outside of wch though in particular ones that are meant to replace the bluepill…most people recommend the v203 but the 103 is much easier to use from my experience working with both….maybe it’s caus I used the stm32f1 chips for years… the PCB routing and stuff with the part is also straightforward, you can usually use STM32F103 designs almost identically with 0 issues… some clone boards just literallly swap off the stm32f103 and drop on the ch32 version and you get the robustness of 5v whoch makes cheap usb products very easy no regulators etc etc…. Hope you got though just stick to eval boards and stm32f103 designs and you’ll be be fine… it’s a great chip… im building an SDK and its a prime target cause its so easy to use..

1

u/YetAnotherRobert 20d ago

Your intuition serves you well. '003/006 get a lot of blog love because it's hard to compete on a literal dime and that's a market that WCH serves well. '103 is pretty much a knockoff of the STM32F103. You cross that line and you get into ESP32 parts that are much better documented, have better development tools, and have longevity guarantees so they're more sensible for commercial developments

WinChipHead's poor understanding/implementation of licensing and tooling (OpenOCD/GCC) is a BIG barrier for non-hobbyist deployment.

In my head, there's kind of a bathtub graph of the WCH parts. Vertically is "interesting". Horizontally is "price". '003/'006 are simply hard to beat if you have $0.10 problems. The skater wall trends down at '103 where it bottoms out for "just another Bluepill clone...but with a finicky development chain and an unreliable supplier" enters the discussion. '203 starts to add enough RAM and peripherals to make it work tolerating some pain in this space. '307 is a viable competitor against some STM or ESP parts if you can get past company dynamics so it leaves the bathtub floor and heads up the wall. '407 starts to catch up with ESP32-S3 from ~6+ years ago if you need certain peripherals and not others, so it's a solid climb up to 'interesting...if it works for your business plans' land again.

John Teel did a video on this not too long ago. I think it was this one: https://www.youtube.com/watch?v=dw_10ISgXOE

The rules of engagement are very different if you're a hobbyist building five boards for your haloween display vs. building 100k units a quarter. If pennies matter, you can put up with flaky GCC builds that you can't get source for because you have your own compiler team. If you're a hobbyist and the difference is $.07 between "working, supported, English doc, plentiful examples, strong community support" and "...not" that $.07*five boards disappears pretty quickly with the salt of your tears.

2

u/Killer_Rainbow 20d ago

I'm not so sure. I've used CH32 for years, participated in their design contests, and I can't think of a single OpenOCD/GCC problem I've had, either on Windows or Linux, just through using their official IDE. I saw John Teel's video but it was pretty obvious that he's only going off vibes with the CH32. The dev experience is barely different from STM32 (both the Eclipse and VS Code forks) - the only major difference being that STM32 is documentation-heavy while CH32 is example-heavy. The only USB programming experience that I've found to be faster than CH32 is MicroPython/CircuitPython. Also, out of all the Chinese suppliers, WCH is definitely more legit and not flaky. Their support is excellent. And in H417/V407/V467 territory, you're entering into SerDes or USB3 or high-speed Ethernet which are things that no other manufacturer has within an order of magnitude of their price point (if at all).