Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
ch32v003fun
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Andreas Horn
ch32v003fun
Commits
d18ad76c
Unverified
Commit
d18ad76c
authored
1 year ago
by
CNLohr
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge pull request #97 from cw2/option-zicsr
Added zicsr arch option. Closes #89
parents
f5ef98ef
186d9dcf
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
examples/exti_pin_change_isr/exti_pin_change_isr.c
+7
-2
7 additions, 2 deletions
examples/exti_pin_change_isr/exti_pin_change_isr.c
examples/self_modify_code/self_modify_code.c
+6
-0
6 additions, 0 deletions
examples/self_modify_code/self_modify_code.c
with
13 additions
and
2 deletions
examples/exti_pin_change_isr/exti_pin_change_isr.c
+
7
−
2
View file @
d18ad76c
...
...
@@ -80,7 +80,13 @@ int main()
// https://github.com/cnlohr/ch32v003fun/issues/90
// https://www.reddit.com/r/RISCV/comments/126262j/notes_on_wch_fast_interrupts/
// https://www.eevblog.com/forum/microcontrollers/bizarre-problem-on-ch32v003-with-systick-isr-corrupting-uart-tx-data
asm
volatile
(
"addi t1,x0, 3
\n
csrrw x0, 0x804, t1
\n
"
:
:
:
"t1"
);
asm
volatile
(
#if __GNUC__ > 10
".option arch, +zicsr
\n
"
#endif
"addi t1, x0, 3
\n
"
"csrrw x0, 0x804, t1
\n
"
:
:
:
"t1"
);
// Configure the IO as an interrupt.
AFIO
->
EXTICR
=
3
<<
(
3
*
2
);
//PORTD.3 (3 out front says PORTD, 3 in back says 3)
...
...
@@ -99,4 +105,3 @@ int main()
asm
volatile
(
"nop"
);
}
}
This diff is collapsed.
Click to expand it.
examples/self_modify_code/self_modify_code.c
+
6
−
0
View file @
d18ad76c
...
...
@@ -46,6 +46,9 @@ uint32_t ReadCSRSelfModify( uint16_t whichcsr )
// The constraints are "ret" is a "write" register, and register a3
// is going to be clobbered by the assembly code.
asm
volatile
(
#if __GNUC__ > 10
".option arch, +zicsr
\n
"
#endif
".global readCSRLabel
\n
"
" fence
\n
"
"readCSRLabel:
\n
"
...
...
@@ -63,6 +66,9 @@ uint32_t ReadCSRSelfModifySimple( uint16_t whichcsr )
uint32_t
ret
;
uint32_t
csrcmd
=
0x000026f3
|
(
whichcsr
<<
20
);
asm
volatile
(
#if __GNUC__ > 10
".option arch, +zicsr
\n
"
#endif
".global readCSRLabel
\n
"
" la a3, readCSRLabel
\n
"
" sw %[csrcmd], 0(a3)
\n
"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment