rp2040

RP2040 Programming without SDK
Log | Files | Refs

commit 622086fcc5ceed2c72aab98a7af66d6a103f9ad3
parent d376a690e119fd335da9ce307531ccdb29cecb01
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Fri, 15 Mar 2024 11:42:37 +0900

try to understand ExceptionEntry and ExceptionExit

Diffstat:
Mex3/main.c | 15++++++++-------
Mex3/proc.s | 4++--
Mex3/start.s | 1+
3 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/ex3/main.c b/ex3/main.c @@ -7,6 +7,7 @@ void halt(void); void *get_sp(void); void wfi(void); void *memcpy(void *s1, void *s2, long n); +void setreg(void); extern char proc0_start, proc0_size; extern char proc1_start, proc1_size; @@ -37,28 +38,22 @@ int main(void) { init(); proc p0, p1; - puts("main"); - puts("main2"); memcpy((void *)0x20000000, &proc0_start, (long) &proc0_size); - puts("main2.5"); memcpy((void *)0x20000100, &proc1_start, (long) &proc1_size); - puts("main3"); p0.r[13] = (void *) 0x20000100; // sp p0.r[14] = (void *) main; // lr p0.r[15] = (void *) 0x20000000; // pc - puts("main4"); p1.r[13] = (void *) 0x20000200; // sp p1.r[14] = (void *) main; // lr p1.r[15] = (void *) 0x20000100; // pc - puts("main5"); for (;;) { + setreg(); wfi(); } - return 0; } @@ -88,6 +83,12 @@ isr_svcall(void) { void isr_alarm(void) { + int *sp = get_sp(); + for (int i = 0; i < 12; i += 1) { + printh(sp+i); + printh(*(sp+i)); + puts(""); + } scheduler(); set_alarm(1000 * 1000); } diff --git a/ex3/proc.s b/ex3/proc.s @@ -28,9 +28,9 @@ get_sp: mov r0, sp bx lr - // Set_reg sets registers for debugging. + // Setreg sets registers for debugging. // Modified registers are: - // ReturnAddress(), LR, R12, R3, R2, R1 and R0. + // LR, R12, R3, R2, R1 and R0. .global setreg setreg: push {lr} diff --git a/ex3/start.s b/ex3/start.s @@ -6,6 +6,7 @@ .global vectors vectors: .word 0x20040000 // 0 initial SP + // "+1" is to indicate that the handlers are thumb functions. .word reset+1 // 1 entry point .word reset+1 // 2 NMI .word isr_hard_fault+1 // 3 hard fault