← back

CH32V003 - What's That?

ThriveS
ThriveS

Shade

Shade
Shade

Hm?

ThriveS
ThriveS

What's this?

Shade
Shade

...A microcontroller?

ThriveS
ThriveS

Yeah, but look at the price

Shade
Shade

Only ten cents?

Shade
Shade

That's... suspiciously cheap. I've used Arduino boards, ESP8266, ESP32. But I've never heard of this one

ThriveS
ThriveS

So?

Shade
Shade

So I guess I'll have to find out what it is

Shade
Shade

Okay. It's a CH32V003, made by WCH

Shade
Shade

It's a 32-bit microcontroller based on WCH's QingKe RISC-V2A core. It can run at up to 48 MHz, has 16 KB of Flash and 2 KB of SRAM, and supports 3.3 V or 5 V operation

ThriveS
ThriveS

So basically a tiny computer

Shade
Shade

Technically, yes

Shade
Shade

While looking into it, I found this EEVblog video

Shade
Shade

The more I looked at the chip, the more interesting it became

Shade
Shade

It's obviously not going to replace an ESP32. Two kilobytes of RAM is laughably small compared to what I'm used to

ThriveS
ThriveS

You say that like two kilobytes isn't enough to run an entire civilization

Shade
Shade

The point is that the CH32V003 isn't trying to be an ESP32 It's an extremely inexpensive general-purpose MCU

Shade
Shade

If all you need is some GPIO, a timer, an ADC, a serial interface, or a small control program, you don't necessarily need a much more powerful chip.

Shade
Shade

Look!

ThriveS
ThriveS

So you bought one

Shade
Shade

Yes

ThriveS
ThriveS

Of course you did

Shade
Shade

Unlike the Arduino ecosystem I'm used to, I couldn't just plug the board in, open Arduino IDE, select a board, and immediately press upload

ThriveS
ThriveS

So we need another IDE

ThriveS
ThriveS

And another programmer

ThriveS
ThriveS

And another utility

Shade
Shade

After installing the necessary tools and getting the WCH-LinkE recognized, I created a simple project in MounRiver Studio.

Shade· c
#include "debug.h"

#define LED_PIN GPIO_Pin_6
#define LED_PORT GPIOD

void GPIO_Config(void)
{
    GPIO_InitTypeDef GPIO_InitStructure = {0};

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOD, ENABLE);

    GPIO_InitStructure.GPIO_Pin = LED_PIN;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

    GPIO_Init(LED_PORT, &GPIO_InitStructure);
}

int main(void)
{
    SystemCoreClockUpdate();
    Delay_Init();

    GPIO_Config();

    while (1)
    {
        GPIO_SetBits(LED_PORT, LED_PIN);
        Delay_Ms(500);

        GPIO_ResetBits(LED_PORT, LED_PIN);
        Delay_Ms(500);
    }
}
ThriveS
ThriveS

Look, the LED is blinking

ThriveS
ThriveS

So... what are we building with it?

Shade
Shade

I don't know yet

ThriveS
ThriveS

Then I have an idea