aboutsummaryrefslogtreecommitdiff
path: root/clocks.s
diff options
context:
space:
mode:
authorJacques Comeaux <jacquesrcomeaux@protonmail.com>2023-12-23 14:12:08 -0600
committerJacques Comeaux <jacquesrcomeaux@protonmail.com>2023-12-23 14:12:08 -0600
commit8f6eed4e102500204879d848572547b35a267cea (patch)
treead5f5138f9068af37d11e20ac6c87e28c3f92d45 /clocks.s
parent987e12b6c90ed3a3606a4948e9d7cad6d6f34026 (diff)
Use crystal oscilator for system clock
Diffstat (limited to 'clocks.s')
-rw-r--r--clocks.s18
1 files changed, 18 insertions, 0 deletions
diff --git a/clocks.s b/clocks.s
new file mode 100644
index 0000000..09a0f6d
--- /dev/null
+++ b/clocks.s
@@ -0,0 +1,18 @@
+.syntax unified
+.cpu cortex-m0plus
+.thumb
+
+.equ CLOCKS_BASE, 0x40008000
+.equ CLK_REF_CTRL_OFST, 0x30
+.equ CLK_SYS_CTRL_OFST, 0x3c
+
+.type setup_clocks, %function
+.global setup_clocks
+
+setup_clocks:
+ ldr r1, =CLOCKS_BASE
+ movs r0, 2 // use xosc (=0x2) as clk_ref source
+ str r0, [r1, CLK_REF_CTRL_OFST]
+ movs r0, 1 // use auxsrc (default pll_sys, =0x1) as clk_sys source
+ str r0, [r1, CLK_SYS_CTRL_OFST]
+ mov pc, lr