-
Notifications
You must be signed in to change notification settings - Fork 64
Clock selection using Arduino IDE menu #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
yes that is very much needed if working with HSI. @TianpeiLee |
@maxint-rd Thank you for your contribution. I am trying to verify your solution and would like to port it to another chip. I am not sure what problem has occurred here. After modifying board.txt and platform.txt, regardless of which clock is selected in the IDE, the result of running is using internal HSI. However, from the compiled log, it does appear that build.flags.clock has already taken effect when generating core. a. So, I would like to know if there is indeed no problem on your end? |
@TianpeiLee : Thank you for addressing this issue. There is also PR #66 by another user that addresses the same issue. To answer your question: as mentioned in my initial post, the system file that defines the clock setting also needed to be changed. For CH32V003 this is: In my local version I commented out all clock related defines. As a global solution it may be better to use some #ifdef 's. For my CH32V003 this worked just fine. Unfortunately I don't have any other member of the CH32 family to check this out. While debugging the V003 behavior I did notice the code to follow to interesting steps. Perhaps these are different for other CH32 MCU's. Finally: I read in another post that your contributions are all done in your spare time. I really appreciate your commitment to maintain this core. Thank you! |
@maxint-rd Thank you for your reply,before testing, I had already commented out the relevant definitions in system_ch32v00x.c, but I still cannot implement clock switching function |
Hmmm... does it work for you on the CH32V003, but not for the others? P.S. Thank you so much for maintaining this core. I really like using the CH32V003 and perhaps will also try some other family members. If you're interested I can also submit PR's for some other core improvements that I only tested for the V003. In my fork of this core you can find branches to implement I2C slave support, an EEPROM emulation library and some other things. |
I tested it on 003 and found that it is only effective for 24M and 8M. Observing the registers, I found that the values of the registers were not set correctly when selecting 48M. I think it should be a hidden small issue , although I haven't found it yet. I am very happy for you to submit a PR's for this repository to improve it, that's really great! I am planning to add the CH32V006 series, which is more like an enhanced 003 and supports hardware multiplication(RV32EC_Zmmul_xw extension). https://www.wch-ic.com/downloads/CH32V006DS0_PDF.html |
Okay, I looked again at your screenshot. Maybe your problem is something small indeed. The person that submitted PR #66 noticed inconsistencies in capitalization and he corrected that too. Note the inconsistent use of capital Z versus lower case z in the MHz/MHZ definition of DSYSCLK_FREQ_48MHZ_HSI and DSYSCLK_FREQ_8MHz_HSI. BTW. That V006 is certainly ingeresting. In my latest projects the main limitation of the V003 was use of flash memory. The 16MB got full quickly, often requiring me to disable features, or not be able to debug.
|
Oh, thank you very much. Yes, I noticed the issue with the capitalization of that letter, and now everything is normal. I am updating it to another chip. The "LTO" option in gcc seems to overly optimize the code under risc-v, causing program exceptions. Currently, this issue has not been resolved. If the Arduino IDE can generate a list file, it may be easier to find problems from assembly code. |
It will be enabled in the next update |
While testing this Arduino core on my CH32V003, I found that using a bare CH32V003 TSSOP20 chip without external crystal requires a change of clock selection in system_ch32v00x.c. Not having the correct clock selected resulted in incorrect timing of millis() and micros(). In my test using the timestamp feature of the IDE, I saw that 500ms actually took a second, which illustrated that the default fallback clock is the 24MHz internal oscillator. Having the internal clock as automatic fallback is a nice feature, but having an IDE user changing core code should be avoided.
To make clock selection easier I modified the files boards.txt, platform.txt and system_ch32v00x.c. I now can select the clock using the menu of the Arduino IDE. I don't have other type of chips for testing, but perhaps you may want to make a similar change.
Changes made:
/packages/WCH/hardware/ch32/1.0.3/system/CH32V00x/USER/system_ch32v00x.c :
=> all clock related defines commented out
/packages/WCH/hardware/ch32/1.0.3/boards.txt :
/packages/WCH/hardware/ch32/1.0.3/platform.txt "
The text was updated successfully, but these errors were encountered: