]> git.ayabusa.dev Git - numworks-zeta-os.git/commitdiff
Started rewrite of the clock (broken)
authorayabusa <lebgpub@gmail.com>
Thu, 18 Apr 2024 18:31:28 +0000 (20:31 +0200)
committerayabusa <lebgpub@gmail.com>
Thu, 18 Apr 2024 18:31:28 +0000 (20:31 +0200)
numworks_port/build/Laplace/clock.o
numworks_port/build/main.bin
numworks_port/build/main.elf
numworks_port/src/Laplace/clock.c

index a3dec5089e10b0cb1e0eec1464b5f29c4c0a9e06..1bfe1237312dc2ffa1c78e64b8406da1ea3b861e 100644 (file)
Binary files a/numworks_port/build/Laplace/clock.o and b/numworks_port/build/Laplace/clock.o differ
index d02b2206ec633b92b2412fab7fa72e431f3779f7..662e0c572141e2360e151b2af06a27e66e8b6d17 100755 (executable)
Binary files a/numworks_port/build/main.bin and b/numworks_port/build/main.bin differ
index 0eff4a1e40d7e3aae3a90ca6a645a3c31bb3c724..2d165beeac7fad56fef62a311c184649284a2d75 100755 (executable)
Binary files a/numworks_port/build/main.elf and b/numworks_port/build/main.elf differ
index 4d5e0e790442e10b69788900e906d0a8ded33e8e..0ad641658e97e32c4fb3c18f30150aeecbafde79 100644 (file)
@@ -2,11 +2,38 @@
 
 /* This should set the speed to 216MHz intead of just 48MHz */
 void init_clock(){
-    // ACR means flash Access control register
+    // Enable the HSI and wait for it to be ready to use
+    RCC->CR    |=  (RCC_CR_HSION);
+    while (!(RCC->CR & RCC_CR_HSIRDY)) {};
+
+    // Enable the HSE and wait for it to be ready to use
+    RCC->CR    |=  (RCC_CR_HSEON);
+    while (!(RCC->CR & RCC_CR_HSERDY)) {};
+
+    // enable power interface clock
+    RCC->APB1ENR |= (RCC_APB1ENR_PWREN);
+
+    // SSGR stuf, paragraph taken from upsilon
+    /* To pass electromagnetic compatibility tests, we activate the Spread
+    * Spectrum clock generation, which adds jitter to the PLL clock in order to
+    * "lower peak-energy on the central frequency" and its harmonics.
+    * It must be done before enabling the PLL. */
+   /* Modper = 250
+    * Incstep = 25
+    * SpreadSel = 0
+    * SSCGEN = 1 */
+    RCC->SSCGR = 0b10000000000000110010000011111010;
+
+}
+
+/* OLD
+// ACR means flash Access control register
     FLASH->ACR |=  (FLASH_ACR_LATENCY_7WS | // 7 wait states
                   FLASH_ACR_PRFTEN |        // prefetch on
                   FLASH_ACR_ARTEN);         // ART on
-
+    
+    FLASH->ACR &= ~(0b00000000000000000000101100001111);
+    
     // enables HSE and wait for it to be ready
     RCC->CR    |=  (RCC_CR_HSEON);
     while (!(RCC->CR & RCC_CR_HSERDY)) {};
@@ -14,12 +41,10 @@ void init_clock(){
     // clear the specified bit
 
     // (8/4)*108 = 216MHz
-    /*
     RCC->PLLCFGR  |=  (RCC_PLLCFGR_PLLSRC_HSE | // HSE: 8MHz
                   RCC_PLLCFGR_PLLN_108 |        // *108
                   RCC_PLLCFGR_PLLM_25);          // /4
-    */
-    RCC->PLLCFGR  =  0b00001000010000100110000000001000; // HSE: 8MHz*/
+    RCC->PLLCFGR  =  0b00001000010000100110000000001000; // HSE: 8MHz
 
     // enable the RCC clock and wait for it to be ready
     RCC->CR    |=  (RCC_CR_PLLON);
@@ -29,4 +54,4 @@ void init_clock(){
     RCC->CFGR  &= ~(RCC_CFGR_SW);
     RCC->CFGR  |=  (RCC_CFGR_SW_PLL);
     while (!(RCC->CFGR & RCC_CFGR_SWS_PLL)) {};
-}
\ No newline at end of file
+*/
\ No newline at end of file