Code from liamg with few edits to init seria comml and output counter.

Dependencies:   mbed

Fork of MKL05CLK by Liam G

Files at this revision

API Documentation at this revision

Comitter:
donoman
Date:
Sat Apr 12 00:54:25 2014 +0000
Parent:
2:1328c14aca66
Child:
4:322eeda5453b
Commit message:
YEAH BOYEE;

Changed in this revision

head.h Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/head.h	Fri Apr 11 02:34:27 2014 +0000
+++ b/head.h	Sat Apr 12 00:54:25 2014 +0000
@@ -1,6 +1,10 @@
-
+//#head.h
 
 #define SIM_SDID              (*(volatile unsigned long *)(0x40048024)) // Kinetis ID register
 #define PORTC_PCR3            (*(volatile unsigned long *)(0x4004B00C)) // PORTC_PCR3 Mux
-#define SIM_SOPT2             (*(volatile unsigned long *)(0x40048004)) // SIM Option Mux            
-#define MCG_C1                (*(volatile unsigned long *)(0x40064001)) // MCG Register 
\ No newline at end of file
+#define SIM_SOPT2             (*(volatile unsigned long *)(0x40048004)) // SIM Option Mux      
+#define SIM_SCGC5             (*(volatile unsigned long *)(0x40048038)) // SIM Option Mux            
+      
+#define MCG_C1                (*(volatile unsigned char *)(0x40064000)) // MCG Register 
+#define MCG_C2                (*(volatile unsigned char *)(0x40064001))
+#define MCG_SC                (*(volatile unsigned char *)(0x40064008))
\ No newline at end of file
--- a/main.cpp	Fri Apr 11 02:34:27 2014 +0000
+++ b/main.cpp	Sat Apr 12 00:54:25 2014 +0000
@@ -2,15 +2,20 @@
 #include "head.h"
 
 Serial pc(USBTX, USBRX); // tx, rx for debug terminal
-Serial testOut(PTC4,PTC3);
+//Serial testOut(PTC4,PTC3);
 DigitalOut myled(LED1);
 
 
 int main() {
     
     int cycle = 0;
+    
+    SIM_SOPT2=0x4010080;
+    MCG_C2=0x25; //fast clock slow clock
+    MCG_SC=0x04; //divider
+    
+    SIM_SCGC5=0xF81;
     PORTC_PCR3=0x501;
-    SIM_SOPT2=0x4010080;
     
     while(true){
         pc.baud(9600);
@@ -23,20 +28,25 @@
         unsigned int ID=0;
         unsigned int FU=0;
         unsigned int FU2=0;
-        unsigned int FU_TIM=0;
+        unsigned char FU_TIM=0;
+        unsigned int FU_MAN=0;
         cycle++;
     
     ID=SIM_SDID;
      FU=SIM_SOPT2;
-    // PORTC_PCR3=0x501;
-    FU2=PORTC_PCR3;
-    FU_TIM=MCG_C1;
+  
+    //FU2=PORTC_PCR3;
+    //MCG_C1=0x3c;
+    
+    FU_TIM=MCG_C2;
+    FU_MAN=SIM_SCGC5;
     
     
     pc.printf("Kinetis ID = %x \n",ID);
     pc.printf("SIM_SOPT2 = %x \n",FU);
-    pc.printf("PORTC_PCR3 = %x \n",FU2);
-    pc.printf("MCG_C1 = %x \n",FU_TIM);
+    //pc.printf("PORTC_PCR3 = %x \n",FU2);
+    pc.printf("MCG_C2 = %x \n",FU_TIM);
+    pc.printf("SIM_SCGC5 = %x \n",FU_MAN);
 
     pc.printf("CycleNo = %d \n", cycle);