commit eb40b0e9cc98390ce77b8e4b5a3c302600444f77
parent ad8444f2be2735a2291e125f3d395d030138b092
Author: Matsuda Kenji <info@mtkn.jp>
Date: Mon, 26 Feb 2024 08:05:07 +0900
use Timer to fire interrupt
Diffstat:
2 files changed, 18 insertions(+), 8 deletions(-)
diff --git a/ex3/boot2.s b/ex3/boot2.s
@@ -3,6 +3,10 @@
.section .boot2
setup_xip:
+ ldr r3, =0x20000000
+ ldr r0, =0xdeadbeef
+ str r0, [r3, #0]
+
ldr r3, rom_base
ldrh r0, [r3, #0x14] // rom_func_table
diff --git a/ex3/main.s b/ex3/main.s
@@ -117,10 +117,12 @@ wait_vco:
ldr r0, =0x20000 //
bl set_alarm
+ ldr r3, =0x20000000
+ ldr r0, [r3, #0]
+ bl printh
+ mov r0, #0
+ str r0, [r3, #0]
loop:
- //ldr r0, =0xdeadbeef
- //bl printh
- svc #0
wfi
ldr r0, =0xcafecafe
bl printh
@@ -129,9 +131,8 @@ loop:
// functions
int_svcall:
- push {lr}
- mov r0, #'\r'
- bl putbyte
+ push {r4, lr}
+ mov r4, lr
mov r0, #'s'
bl putbyte
mov r0, #'v'
@@ -144,9 +145,13 @@ int_svcall:
bl putbyte
mov r0, #'l'
bl putbyte
+ mov r0, r4
+ bl printh
+ mov r0, #'\r'
+ bl putbyte
mov r0, #'\n'
bl putbyte
- pop {pc}
+ pop {r4, pc}
int_systick:
push {lr}
@@ -162,6 +167,7 @@ int_systick:
pop {pc}
int_alarm:
+ mov r0, sp
push {lr}
// clear interrupt
ldr r3, timer_base
@@ -169,7 +175,7 @@ int_alarm:
mov r1, #0x34
add r1, r1, r2
mov r0, #1
- str r0, [r3, r2] // TIMER: INTR
+ str r0, [r3, r1] // TIMER: INTR
// reset timer
ldr r0, =0x20000 // 1 sec
bl set_alarm