CH32V003F4P6 arduino support

Hi,

I am currently testing a CH32V003F4P6 (20 pins) alone (without using a development board).
I’m trying to use pins PA1 and PA2 (designed for an external clock) as standard inputs/outputs.
I use the pinmode and digitalWrite functions without success. Is there a reconfiguration of these 2 pins to be carried out? If yes, do you have an idea for a resolution, an example script?

THANKS.

1 Like

To free up PA1 and PA2 from being used for highspeed oscillator, change the clock source to be from HSI 48MHz (highspeed internal) instead of HSE 48MHz, by using

build_flags =
  -DSYSCLK_FREQ_48MHZ_HSI=48000000

in the platformio.ini (in reference to this code). This specifically prevents this code from being executed

that executes the remap from GPIO to oscillator function.

Hi Max,

Thank you for your feedback, it’s perfect.

I will still benefit from your expertise.
I have another question: I’m trying to set up 2 external interrupts on PC4 and PD0.


attachInterrupt(digitalPinToInterrupt(PC4),GPIO_Mode_IPD,buttonPressed1,EXTI_Mode_Interrupt,EXTI_Trigger_Rising);
   attachInterrupt(digitalPinToInterrupt(PD0),GPIO_Mode_IPD,buttonPressed2,EXTI_Mode_Interrupt,EXTI_Trigger_Rising);

The interrupts are raised but the 2 methods are called.

Do you have an idea of the solution?

THANKS.

This is a known issue and would be fixed by

But the author has to yet merge this. They’re probably busy with chinese new year celebrations.

If you want to fix that now, you would have to manually patch these core functions ( C:\Users\<user>\.platformio\packages\framework-arduino-openwch-ch32) :frowning:

1 Like

Too fast, thank you for your feedback.
While waiting for the update, I patched the file and it works :wink:

2 Likes