Patrick Fitzgerald
Published © GPL3+

Program CH32V003 RISC-V with Arduino IDE

Add OpenWCH boards package to your Arduino IDE and program RISC-V chips.

IntermediateProtip2 hours5,281

Things used in this project

Hardware components

CH32V003 Development Board Kit 32-bit general-purpose RISC-V MCU
×1
WCH LinkE Online Download Debugger Support WCH RISC-V Architecture
×1
Dupont Jumper Wire Double Female
×1

Software apps and online services

Arduino IDE
Arduino IDE
OpenWCH ArduinoCore
Zadig USB Driver

Story

Read more

Code

BlinkCH32V003

Arduino
Demo program for MCU boards with CH32V003F4P6 chips
written with built in LED attached to PD0
will not compile until OpenWCH arduino board package is added
void setup() {
    pinMode(PD0, OUTPUT); }
void loop() {
    digitalWrite(PD0, HIGH);
    delay(250);
    digitalWrite(PD0, LOW);
    delay(250);
}   

arrayToggle.ino

Arduino
Arduino sketch to toggle entire ports/pins on RISC-V devboard
works with OpenWCH boards package for arduino IDE
uncomment only one array p[ ]
// toggles entire ports blinky style
// uncomment only one array for pins[ ]
// int pins[] = {/* PA0,*/ PA1 ,PA2 /*,PA3,PA4,PA5,PA6,PB7 */};
// int pins[] = {/*PB0, PB1, PB2 ,PB3 ,PB4 ,PB5 , PB6 ,*/ PB7/**/};
// int pins[] = {PC0,PC1,PC2,PC3,PC4,PC5,PC6,PC7};
int pins[] = { PD0, PD1, PD2, PD3, PD4 , PD5, PD6, PD7 /* */};
int pinCount = sizeof(pins);
void setup() {
  for (int pin = 0 ; pin < pinCount ; pin++) {
    pinMode(pins[pin], OUTPUT);  }}
void loop() {
    for (int pin = 0 ; pin < pinCount ; pin++){ 
      digitalWrite(pins[pin], HIGH); }
    delay(200);
    for (int pin = 0 ; pin < pinCount ; pin++){ 
      digitalWrite(pins[pin], LOW); }  
    delay(200);
}

Credits

Patrick Fitzgerald
124 projects • 44 followers
Contact

Comments

Please log in or sign up to comment.