
I have a CH32V003 version.with 42 LEDs now and could not get Arduino to work with it before. I now looked into it again and am very close to uploading to the SAO from Arduino.
First I had to make the compiling for the Adafruit_Neopixel library work. There's an issue with the hardware flag. You have to change the library slightly to work with the arduino core.
Arduino Core: https://github.com/openwch/arduino_core_ch32
Fix: https://forum.arduino.cc/t/ch32v003p4-sleep-and-wakeup/1290315/18
Change anything in .c and .h file from
defined(ARDUINO_ARCH_CH32)
to this:
defined(ARDUINO_ARCH_CH32) || defined(CH32V00x)
Then I had to change some doubles to floats variables, hopefully all the libs still work. Also added a const to the fixed variables to move them to Program Flash.
The Arduino compiler is missing a flag for the CH32V003 to run with the internal 48MHz oscillator - something I later noticed by testing the hackaday CH32V003 supercon addon with a simple 1sec blink sketch. Reading this issue I thought it was fixed, but the blink don't lie. So following the issue I added the following flag to the compiler steps. This will basically break compiling for every other CH32 chip though, so be aware.
https://github.com/openwch/arduino_core_ch32/issues/27
# the tag: -DSYSCLK_FREQ_48MHZ_HSI=48000000
compiler.S.flags= -DSYSCLK_FREQ_48MHZ_HSI=48000000 ...
compiler.c.flags= -DSYSCLK_FREQ_48MHZ_HSI=48000000 ...
compiler.cpp.flags= -DSYSCLK_FREQ_48MHZ_HSI=48000000 ...
Uploading with the linux computer works, but with my mac I run into a libusb problem, that complains about the installed libusb architecture of my computer being wrong. After a few "chatGPT tells me to install new homebrew versions with rosetta" episodes I just gave up. You can also just upload the binary file you can export from arduino onto the CH32V003 by using minichlink.
./minichlink -w whateverfile.ino.bin flash
Side note: I had to again update the LED arrangement array
const uint8_t circular[4][12] = {
{ 0, 1, 2, 3, 4, 5, 255, 255, 255, 255, 255, 255},
{ 8, 9, 13, 14, 18, 19, 29, 24, 34, 35, 39, 40 },
{ 7, 10, 12, 15, 23, 20, 28, 25, 33, 30, 38, 41 },
{ 6, 11, 17, 16, 22, 21, 27, 26, 32, 31, 37, 36 }
};
davedarko
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.