-
Notifications
You must be signed in to change notification settings - Fork 158
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
Problem with adding CH32x035 example (cap_touch_adc) #479
Comments
What happens when it tries to execute the |
Of course, sorry I forgot: Right after executing
|
As far as I can see...
I'm not familiar with the CH32x035 - is there any reason that this instruction would be unsupported on that MCU? |
I had a similiar issue when trying to use parts the of systick_irq example in one of my projects, it crashed when calling |
I don't see how that would help or how that's relevant here. Did you check your disassembly against what I posted above? |
Well, there is no csrrs in the disassembled file. At address The strange thing is, during debugging, it's executing |
Are you sure that you're compiling the program with something like |
I added |
Found this thread: https://github.com/eugene-tarassov/vivado-risc-v/issues/181 EDIT: Looking at the reference manuals of ch32v003 and ch32x035, I found out, ch32v003 doesn't seem to have a PMP, thus this code works for ch32v003, but not for ch32x035 since it introduces memory access restrictions. |
RISC-V boots into machine mode and will only enter a lower privilege mode, such as user mode, if there is (usually boot) code to do this. As you say this would normally only be an issue when using an [RT]OS that runs the kernel in machine mode and user threads/programs in user mode. I presume that that's not relevant in your case? (Does the CH32x035 MCU even support modes other than machine mode? I don't know and can't seem to access the WCH datasheet page lately).
I think that you're going down the wrong track here to be honest. If the |
Good question. Since the Ch32x035 has a PMP, it seems it can work in different modes. See reference manual on page 51.
Well, I'm working on it. The datasheet says: "[...]the PMP unit is always in effect in user mode, and optionally in machine mode, |
I ended up adding:
to ch32v003fun.c in the Seems to work, at least I don't get |
According to https://github.com/WuxiProject-offical/CH32X035-HelperLibrary/blob/main/startup_file/startup_ch32x035_highcode_machine.S this enters machine mode and enables global interrupts. Link doesn't work. I presume that you meant this? |
I doubt that the device boots into anything other than machine mode and, in any case, the startup/reset code in question is writing to FWIW this is what the WCH EVT does at startup:
|
Well, I can only draw conclusions from what the official documentation tells me. Assumptions lead nowhere.
But where is the ch32v003fun framework doing this?
That's it. |
@TommyMurphyTM1234 Re: mstatus, we set it right here: https://github.com/cnlohr/ch32v003fun/blob/master/ch32v003fun/ch32v003fun.c#L1012-L1020 - what is the issue there? In general, why are there so many links here to WuxiProject? I am available now, but I am really confused, what is the current issue you are having? |
I haven't asserted that there's any issue with what ch32v003fun does with
Me too. :-( |
@yves5141 I still can't make heads or tails of what you're saying. ch32v003fun performs this operation https://github.com/cnlohr/ch32v003fun/blob/master/ch32v003fun/ch32v003fun.c#L1012-L1020 I don't think you're looking at ch32v003fun. |
Hi,
I'm trying to make some of the examples work on a CH32x035G8U6.
But at the moment I'm struggling with the cap_touch_adc example.
I changed line 54 in ch32v003_touch.h, since CH32x035 has a 64-bit counter for SysTick.
For testing, I changed cap_touch_adc.c, in order to get values only from PA0.
However, the program crashes and jumps to line 767 in ch32v003fun.c (
while( !DebugPrintfBufferFree() );
). I did some debugging, the code works until it gets to line 87 in ch32v003_touch.h, switching to assembly, it happens at 0x00000734:I'm not sure, how to solve this.
BTW: Not directly related, but I couldn't find a document for the CH32x035 containing the instruction set and listing all the registers. Where can I find that?
ch32v003_touch.h
cap_touch_adc.c
The text was updated successfully, but these errors were encountered: