]> git.ayabusa.dev Git - numworks-zeta-os.git/commitdiff
made this shitty clock work
authorayabusa <lebgpub@gmail.com>
Fri, 19 Apr 2024 16:26:14 +0000 (18:26 +0200)
committerayabusa <lebgpub@gmail.com>
Fri, 19 Apr 2024 16:26:14 +0000 (18:26 +0200)
numworks_port/README.md
numworks_port/build/Laplace/clock.o
numworks_port/build/Laplace/time.o
numworks_port/build/main.bin
numworks_port/build/main.elf
numworks_port/build/main.o
numworks_port/src/Laplace/clock.c
numworks_port/src/Laplace/clock.h
numworks_port/src/Laplace/time.h
numworks_port/src/main.c

index 6957788659b46d6622f5dabd4b7d5a37f391b267..788650952b9dfcc082294b94554a1716f89a24f6 100644 (file)
@@ -13,13 +13,11 @@ This is a bare metal os attempt on the numworks n0110
 - [x] Working thing
 - [x] Led interface
 - [x] Keyboard interface
-- [ ] Set clock and all
-    - [ ] adapt ms_wait() and us_wait()
+- [x] Set clock and all
+    - [x] adapt ms_wait() and us_wait()
 - [ ] Screen interface
 - [ ] UI toolkit
     - [ ] set pixel
     - [ ] text display
     - [ ] fill rect
-    - [ ] image display
-- [ ] File system
-    - [ ] Plan what to do
\ No newline at end of file
+    - [ ] image display
\ No newline at end of file
index 1bfe1237312dc2ffa1c78e64b8406da1ea3b861e..bcff223f382c2dab081442c3053f0797a167d133 100644 (file)
Binary files a/numworks_port/build/Laplace/clock.o and b/numworks_port/build/Laplace/clock.o differ
index bc8f70a863612ac4be5d55b4e984dddd28553826..ccb66eb0f543507c7e82484561876100bd533580 100644 (file)
Binary files a/numworks_port/build/Laplace/time.o and b/numworks_port/build/Laplace/time.o differ
index 662e0c572141e2360e151b2af06a27e66e8b6d17..a09e114a5d427c5ee553ef1968c6ffa54e2a5f31 100755 (executable)
Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ
index 2d165beeac7fad56fef62a311c184649284a2d75..be4345c890370838e8734792c252e960331f29a7 100755 (executable)
Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ
index a89f7cbc9b9894c74907c3a5e3a271d9da42fe86..b825c0197079124d243ec7b5ed4fa0cecc045dab 100644 (file)
Binary files a/numworks_port/build/main.o and b/numworks_port/build/main.o differ
index e70558e818d5de633cff39c6da63a248feebbcbc..733768b4e6eea919b45594f5c14dc7d781aa3a81 100644 (file)
@@ -54,8 +54,32 @@ void init_clock(){
      * wait a little bit.
      * The spec tells us that at 2.8V and over 210MHz the flash expects 7 WS. */
     // clear in first place
-    FLASH->ACR &= ~(0b0000 0000 0000 0000
-                      0000 0011 0000 1111);
+    FLASH->ACR &= ~(FLASH_ACR_LATENCY_Msk | FLASH_ACR_PRFTEN | FLASH_ACR_ARTEN);
+    FLASH->ACR |= (FLASH_ACR_LATENCY_7WS | FLASH_ACR_PRFTEN | FLASH_ACR_ARTEN);
+
+    // 192MHz is too fast for both APB1 and APB2 so we divide them 
+    // firstly we clear
+    RCC->CFGR &= ~(0b00000000000000001111110000000000);
+    /* Then we set
+     * PPRE1 = 4 = 100
+     * PPRE2 = 2 = 10 */
+    RCC->CFGR |= 0b00000000000000001001010000000000;
+
+    // We now wait for PLLRDY
+    while (!(RCC->CR & RCC_CR_PLLRDY)) {};
+
+    // We select PLL output as a SYSCLK source
+    RCC->CFGR |= RCC_CFGR_SW_PLL;
+    // And wait for it !!!
+    while ((RCC->CFGR & RCC_CFGR_SWS_Msk) != RCC_CFGR_SWS_PLL) {};
+
+    // We can now disable HSI
+    RCC->CR &= ~(RCC_CR_HSION);
+
+    // Set normal speed
+    RCC->CFGR &= ~(RCC_CFGR_HPRE_Msk);
+
+    set_led_green(true);
 }
 
 /* OLD
index 912058617702dbee94a3711da746b6bd11361e07..da7fd2f2580a1fb62c34e05d2f1ec60226d3ddea 100644 (file)
@@ -9,11 +9,7 @@
 
 #include "stdint.h"
 #include "../device/stm32f730xx.h"
-
-#define PLL_N 384
-#define PLL_M 8
-#define PLL_P 2
-#define PLL_Q 8
+#include "led.h"
 
 /*
 RCC->PLLCFGR  |=  0b00001000010000100110000000001000; // HSE: 8MHz*/
index 99c1af2990c8edcf6e10285aded8e1633cbc5bdb..472f8f6deccb2bb00d1469ea0ba6e065c82a413e 100644 (file)
@@ -8,7 +8,7 @@
 #define TIME_H
 
 #define loops_per_microsecond 1
-#define loops_per_millisecond 960
+#define loops_per_millisecond 12000
 
 #include "stdint.h"
 
index 079e576e1df82a98eb1cc488a7b8909e96c5da1e..235f83e120485dc0aa7528f38a2c97af6568796e 100644 (file)
@@ -33,9 +33,9 @@ void main_entry(){
             set_led_red(false);
         }*/
 
-        set_led_red(true);
+        set_led_blue(true);
         ms_wait(5000);
-        set_led_red(false);
+        set_led_blue(false);
         ms_wait(5000);
     }