rp2040

RP2040 Programming without SDK
Log | Files | Refs

commit 9b0c7c0acbd703df14bd4ecd0a94a88da9c60eef
parent da7c10f1af1e710db3abf8e85dab3bcd0e74ea0a
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Tue, 12 Mar 2024 07:51:29 +0900

add hardfault handler, thought it just reports the fault for now

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

diff --git a/ex3/main.c b/ex3/main.c @@ -30,7 +30,7 @@ proc_tab *ptab; int main(void) { init(); - + puts("reset"); proc *p0 = (proc *) 0x20041000, *p1 = (proc *) 0x20041100; // sram5 memcpy((void *)0x20000000, (void *)&proc0_start, (long) &proc0_size); @@ -53,6 +53,12 @@ scheduler(void) { } void +isr_hard_fault(void) { + puts("hard fault"); + halt(); +} + +void isr_svcall(void) { puts("svcall"); } diff --git a/ex3/proc.s b/ex3/proc.s @@ -6,7 +6,7 @@ proc0: bl puts b proc0 - .align 2 + .align 4 .global msg0 msg0: .asciz "proc0" diff --git a/ex3/start.s b/ex3/start.s @@ -7,8 +7,8 @@ vectors: .word 0x20040000 // 0 initial SP .word reset+1 // 1 entry point - .word reset+1 // 2 - .word reset+1 // 3 + .word reset+1 // 2 NMI + .word isr_hard_fault+1 // 3 hard fault .word reset+1 // 4 .word reset+1 // 5 .word reset+1 // 6 @@ -279,6 +279,11 @@ rxfe: and r0, r0, r1 bx lr + .global halt +halt: + wfe + b halt + // The following functions make no side effects and // can be used anywhare without pushing and popping // registers.