Mark Gottscho / HardwareTimersLib

Fork of HardwareTimersLib by Mark Gottscho

Revision:
11:e0442c8b182b
Parent:
9:dff7c891ec77
Child:
12:cb395e4be69e
--- a/Timer_LPTMR.cpp	Tue Mar 11 04:18:04 2014 +0000
+++ b/Timer_LPTMR.cpp	Tue Mar 11 04:54:13 2014 +0000
@@ -39,11 +39,15 @@
     uint16_t ticks;
     uint32_t count;
     
-    __disable_irq(); //CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
+    //__disable_irq(); //CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
     LPTMR0->CNR = 0; //need to write to the register in order to read it due to buffering
     ticks = (uint16_t) LPTMR0->CNR;
+    
+    //It is theoretically possible that the timer interrupt is invoked here, between these two lines.
+    //However, the timer doesn't appear to work properly if I put these two in a critical section.
+    
     count = __count;
-    __enable_irq(); //END CRITICAL SECTION
+    //__enable_irq(); //END CRITICAL SECTION
     
     //Convert to ticks
     return (uint32_t) count * __rolloverValue + ticks;