CH32V307VCT6 development board design

Hello,

Just to add my experience about this MCU, and the development of a similar board just as the dev kit:

My design is much closer to the Arduino Uno footprint, so I did several changes in my design. The schematic I will post when I make sure everything works as expected.

For the software support and Arduino IDE, I use this package:

First problem I faced was with some undeclared pins. Just like the guy here.

I managed to bypass this problem by editing variant_CH32V307VCT6.h file by adding few missing pins, not all of them for now.

 #define PD10                    22
 #define PD11                    23
 #define PD12                    24
 #define PD13                    25
 #define PD14                    26

And change the #define NUM_DIGITAL_PINS to 27, again for now.

Then, I needed to change the variant_CH32V307VCT6.cpp file by adding what is missing, too.

   PB_13,  //D19    SPI2_SCK 
   PB_11,  //D20    I2C2_SDA
   PB_10,  //D21    I2C2_SCL
   PD_10,  //D22
   PD_11,  //D23
   PD_12,  //D24
   PD_13,  //D25
   PD_14   //D26

With a simple Blink sketch, I managed for my LEDs to blink. So far, so good. Same goes for the Key input.

So, the regular inputs and outputs work fine, by uploading the sketch with the WCH-LinkE. The idea is to have the programmer onboard, just as the original dev kit.

To do:

  1. Host USB
  2. OtG USB
  3. Ethernet
  4. Onboard programmer

I will keep you in touch.

1 Like

So far so good!

Onboard programmer.

So the board have the same CH549G chip as an onboard programmer which uses the RISC V firmware as a WCH Link. There are three ways to upload a firmware on a brand new CH549G. My board, as well as the original, have USB, SWD and UART pins from the CH549G broken out. In any case, you can use the WCH-LinkUtility, the WCHISPStudio, or the Mount River Studio, as the WCHISPStudio is a standalone part of the IDE. Next, you need the wch_linkutility as a ZIP package. Everything you can get from the official WCH pages. Just in case, here are the links:

Next is to set the chip into a boot mode by connecting the D+ (USB D+) to its internal 3.3V power line while connecting it to a power. On original board there is a J1 PTH, mine board, too. You just have to short this while powering up.

Next step is to open the WCHISPStudio, as by this way, the studio will recoginze the chip and set almost all parameters. According the way you want to program the firmware on the CH549G, you have to set DnId port (USB, Serial).

I made this by connecting the board to a PC over the USB. This way, as a DnId port, I choose USB, select the WCH-Link_APP_IAP_RV.bin from the ZIP file and check boxes for Clear Data Flash, and Clear Code Flash. Next is Download. Everything went smoothly and after reconnecting the board to a PC over the same USB, but this time not shortening the J1, the PC recognized the board (and the CH549G) as a WCH-LinkRV.

In Arduino IDE, I didn't had to change a thing. I just uploaded the sketch, and everything went fine.

I said there are three ways to do this. Second way is to use the serial TTL adapter. Some FTDI will do the job. Connect the UART lines (RX/TX and vice versa), 5V, and GND. In the WCHISPStduio you have to select Serial and COM port, the rest is the same.

Third way is to use another WCH-Link and the WCH-LinkUtility.

PS.
Thanks @pert for placing this in the right forum

2 Likes

Let's continue with the tests.

I am using core package I mentioned earlier.
A standard AnalogReadSerial example on PA0 with an LDR and a 10K resistor shows everything works as expected. Except that the delay I set to 100 ms as the MCU is so fast that it couldn't print the data as it reads. So this test proves that the ADC (12-bit) and the Serial output (serial terminal) works good. The output was in a range of 0 to 4096.

Next...

1 Like

Let's move on.

I2C

I tested it with two I2C devices: OLED SSD1306 and BME280. The I2C scanner showed them both. The library compatibility is the problem. While I couldn't make both devices to work with Adafuit libs, I made the display work with the U8G2 lib.

#include <Arduino.h>
#include <U8g2lib.h>
#include <Wire.h>
U8G2_SSD1306_128X64_NONAME_1_HW_I2C u8g2(U8G2_R0, U8X8_PIN_NONE);
void setup(void){
  u8g2.begin();  
}
void loop(void){
  u8g2.firstPage();
  do {
    u8g2.setFont(u8g2_font_ncenB10_tr);
    u8g2.drawStr(0,24,"Hello World!");
  } while ( u8g2.nextPage() );
}

So far, so good. The libraries incompatibilities are expected.

Now I can say that my design is ok. This is the schematic of the board I designed. You can see it is closely based on the original design.

There are, however parts not tested yet, so, the schematic might be changed in a future. I hope not.

2 Likes

Nice. Are you able to flash the CH32V via CH549G using USB like the Arduino on the fly? If yes, that would be really useful for students.

Yes. I explained it in post #2

Oh, did not get that. Anyway, nicely done :+1:

Not to forgot, the I2C pins I used for the OLED are:
SCL PB10
SDA PB11

The variant pinout can be checked here:

The SPI

I tried the BMP280 and SPI connection, and everything worked like a charm.
I used an Adafruit lib. The pins I used are:

SS PA4
SCK PA5
MOSI PA7
MISO PA6

Now, the tricky parts:
Host USB
OtG USB
Ethernet

PS.
For Serial print I had to add a delay here and there, as for the Adafruit example as is, the MCU was so fast so it couldn't print it at all.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.