commit a7498c2d173c011455b8bfb0b85f00b23eda532a
parent db25ac26d23f9e898a0807bebc2651b9e3c33314
Author: Matsuda Kenji <info@mtkn.jp>
Date: Fri, 23 Feb 2024 08:14:20 +0900
count ticks using systick timer
Diffstat:
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/ex3/main.s b/ex3/main.s
@@ -67,6 +67,9 @@ wait_vco:
mov r0, #1
lsl r0, r0, #11
str r0, [r3, #0x48] // CLOCKS: CLK_PERI_CTRL
+ // set clk_ref to xosc
+ mov r0, #2
+ str r0, [r3, #0x30] // CLOCKS: CLK_REF_CTRL
// setup uart0
ldr r3, uart0_base
@@ -85,8 +88,22 @@ wait_vco:
ldr r0, =(3 << 5 | 1 << 4) // WLEN = 8, FEN = 1
str r0, [r3, #0x2c] // UART: UARTLCR_H
+ // set systick timer
+ ldr r3, ppb_base
+ ldr r0, =0xffffff
+ ldr r1, =0xe014
+ str r0, [r3, r1] // M0PLUS: SYST_RVR
+ // enable systick timer
+ sub r1, r1, #4
+ mov r0, #1
+ str r0, [r3, r1] // M0PLUS: SYST_CSR
+
+ mov r4, r3
+ ldr r5, =0xe018
loop:
- bl getbyte
+ ldr r0, [r4, r5] // M0PLUS: SYST_CVR
+ bl printh
+ ldr r0, ='\r'
bl putbyte
b loop
@@ -219,3 +236,5 @@ uart0_base:
.word 0x40034000
sio_base:
.word 0xd0000000
+ppb_base:
+ .word 0xe0000000