Andrew Boyson / clock

Dependents:   oldheating gps motorhome heating

Revision:
19:e537bacd1478
Parent:
18:207dd1474cd9
Child:
20:62e0760cae13
--- a/tick.c	Tue Jan 16 17:38:12 2018 +0000
+++ b/tick.c	Wed Jan 17 20:42:14 2018 +0000
@@ -112,7 +112,6 @@
     slew = 0;
     nsCountIsSet = false;
     
-    LPC_SC->PCONP    |=     4; //  4.8.9 Power Control for Peripherals register - Timer1 Power On
     LPC_TIM1->TCR     =     2; // 21.6.2 Timer Control Register - Reset TC and PC.
     LPC_TIM1->CTCR    =     0; // 21.6.3 Count Control Register - Timer mode
     LPC_TIM1->PR      =     0; // 21.6.5 Prescale register      - Don't prescale 96MHz clock (divide by PR+1).
@@ -126,3 +125,17 @@
     *pLastTime = thisTime;
     return elapsed;
 }
+uint32_t TickTimerStart()
+{
+    return LPC_TIM1->TC;
+}
+uint32_t TickTimerCount(uint32_t startCount)
+{
+    uint32_t thisCount = LPC_TIM1->TC;
+    return thisCount - startCount; 
+}
+uint32_t TickTimerMs(uint32_t startCount)
+{
+    uint32_t count = TickTimerCount(startCount);
+    return count / 96000;
+}