rp2040

RP2040 Programming without SDK
Log | Files | Refs

commit 27af25bb882a8c50c2c7e0290eb6c77a166f9886
parent 622086fcc5ceed2c72aab98a7af66d6a103f9ad3
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sat, 16 Mar 2024 08:11:56 +0900

read special registers

Diffstat:
Mex3/main.c | 6+++++-
Mex3/proc.s | 7+++++++
2 files changed, 12 insertions(+), 1 deletion(-)

diff --git a/ex3/main.c b/ex3/main.c @@ -8,6 +8,7 @@ void *get_sp(void); void wfi(void); void *memcpy(void *s1, void *s2, long n); void setreg(void); +void print_sr(void); extern char proc0_start, proc0_size; extern char proc1_start, proc1_size; @@ -51,6 +52,7 @@ main(void) { p1.r[15] = (void *) 0x20000100; // pc for (;;) { + print_sr(); puts(""); setreg(); wfi(); } @@ -84,9 +86,11 @@ isr_svcall(void) { void isr_alarm(void) { int *sp = get_sp(); + print_sr(); + puts(""); for (int i = 0; i < 12; i += 1) { printh(sp+i); - printh(*(sp+i)); + printh((void *)*(sp+i)); puts(""); } scheduler(); diff --git a/ex3/proc.s b/ex3/proc.s @@ -44,3 +44,10 @@ setreg: mov r3, #3 nop pop {pc} + + .global print_sr +print_sr: + push {lr} + mrs r0, ipsr + bl printh + pop {pc}