openwch / arduino_core_ch32

Core library for CH32duino
269 stars 52 forks source link

Add Adafruit qtpy ch32v203 board #136

Closed hathach closed 2 months ago

hathach commented 3 months ago

Add support for Adafruit qtpy ch32v203g, which is the main reason for my effort (on behalf of Adafruit) for porting tinyusb to ch32v core as well as recent PRs. Boards is tested with neoixel, i2c, spi, uart2 all working well, for more info. Hopefully @ladyada would make more of ch32v hardware if that gain popular enough (and she could manage the time).

Note:

What menu looks like after merged. image

ladyada commented 3 months ago

thanks @hathach !

maxint-rd commented 3 months ago

Hello @hathach, for my CH32V003 project I needed to enable the Watchdog and also wanted to use sleep. When looking for some Arduino standard I found that the Adafruit_SleepyDog library provided the broadest universal support. A moment ago I published a fork of Adafruit_SleepyDog that supports the CH32V003.

Other than perhaps some cleanup I think this version could already be useful for testing by other people. Unfortunately I don't have any other CH32 chips, so I couldn't add support for those. I did see in the core code that other chips use different EXTI_Line registers for implementing sleep(), but have no hardware to test that. Did you already have a look at supporting sleep for the CH32V203?

ladyada commented 3 months ago

we have no plans to add more library supports at this time so PRs are welcome! please submit a PR and you can tag @hathach to get a review for that library

maxint-rd commented 3 months ago

Hello @ladyada - thanks for the swift reply. When I have time I will do some cleanup and submit that PR. And before I forget: a big THANKS to Adafruit for making all those libraries to support a large community of makers, including myself.

hathach commented 2 months ago

@TianpeiLee sorry to bother your, would you please review this since we already launch the product for a few weeks. We could contribute to maintain support for our boards should there is any issue with it.

TianpeiLee commented 2 months ago

Hello, sorry for not processing it in time

TianpeiLee commented 2 months ago

@hathach image

What does 224KB mean?

TianpeiLee commented 2 months ago

@hathach https://www.adafruit.com/product/5996 I already got it from here ,thank you !

hathach commented 2 months ago

@TianpeiLee thank you for merging the PR.

What does 224KB mean?

For your question, all v203 always has 224KB of flash, however, only 32K/64K is zero-wait state i.e fast flash. The rest is considered as slow flash, which requires to enable Flash Enhanced Read mode for stability, which we implemented in pre_init() for qtpy variant (check diff comment above). In our testing, it can run with application exeeding normal 32KB without any issues. I guess it will slow down a bit but not really notable with most arduino user.

Note: openocd only flash 32Kb due to its algorithm, to flash the whole elf up to full 224KB we need to either use wchisp (bootrom) and/or wchlink

from datasheet image

from manual image

Ref: article https://cpldcpu.wordpress.com/2024/05/01/decapsulating-the-ch32v203-reveals-a-separate-flash-die/

PS: Let me know if these make sense to you, or if you need any more clarification

TianpeiLee commented 2 months ago

thank you for your explanation