UART problem CH32V307CT6

Well! This is embarrassing.
It turns out that I DO have a CH32V307 eval board (bought in May 2024.)
I just put it in a box and never did anything with it :frowning:
Not the same one you have, though. I got:

I would like this board, as almost all the MCU’s I/O lines are available on the edge connectors, allowing the user to perform a wide range of experiments using alternate functions. In contrast, the UNO R4 (RA4M1 MCU with 84 IO lines) / UNO Q (STM32U585 with 140 IO lines) expose only 20 I/O lines to the user via edge connectors.

Well, I have this working (uploads Blink, etc.)
And I've been looking at the core code...

It looks about like you'd expect it to, if you hired a summer intern and said "add Arduino support for this chip." (ie "not good") And then they went away, and there wasn't enough "customer interest" to continue development.

  • You've already noticed that only a small subset of the pins are defined for access from Arduino.
  • The pins that ARE defined are not done in the correct order. At least, not for the several existing eval boards that are laid out to support Uno-format shields. (pin 0-4 are analog pins 0-4, for example.)
  • Only the one Serial port is defined.
  • The Serial code is not interrupt driven.
  • The main "interest" on the github repository seems to be for the smaller chips (especially the very cheap 003 varieties.)
  • The latest "release" via the Arduino Board Manager is well behind the source code on github, and it has bugs (ie on my board, Blink ran about 10x too slow.)
  • Some of these issues have existing patches and submitted pull requests, but they're not being merged; I don't know if there is any active development going on.

Your summary matches my findings. Your EVT board has many more pins than the board I have, and probably different “blink” pins, most of the rest undefined in any available code.

Sniff. My great idea for expanding the pins array, involving designated initializers, didn't work :frowning:

const PinName digitalPin[] = {
  PA_10,  // D0
   :
#ifdef ALLPINS
  // All the pins.  
  // Arduino pins for all of them.
  [PIN_PA0] = PA_0,
  [PIN_PA1] = PA_1,
  [PIN_PA2] = PA_2,
  [PIN_PA3] = PA_3,

sorry, unimplemented: non-trivial designated initializers not supported

(The "test case" went fine, but that was using the desktop's clang. Hmmph.)

Nice try. I found the Teensy 4.1 just works; fast, has 8 UARTS, Ethernet, lots of other pins, and breadboard friendly shape, well supported; pin sheets, examples etc.

For other readers: PR #201 provides interrupt driven serial. I've done some experiments with dual serial support as well. There are many more useful PRs. Unfortunately WCH hasn't merged these into a new release.