Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of HardwareTimersLib by
Diff: Timer_PIT.cpp
- Revision:
- 9:dff7c891ec77
- Parent:
- 8:23c04123395c
- Child:
- 11:e0442c8b182b
diff -r 23c04123395c -r dff7c891ec77 Timer_PIT.cpp
--- a/Timer_PIT.cpp Tue Mar 11 02:42:03 2014 +0000
+++ b/Timer_PIT.cpp Tue Mar 11 03:56:01 2014 +0000
@@ -36,13 +36,14 @@
if (!__valid)
return 0;
- // CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
- __disable_irq();
- uint32_t tick = PIT->CHANNEL[0].CVAL; //counts down
- uint32_t count = __count;
- __enable_irq();
- // END CRITICAL SECTION
-
+ uint32_t tick;
+ uint32_t count;
+
+ __disable_irq(); //CRITICAL SECTION -- ALL INTERRUPTS MUST BE STOPPED!
+ tick = PIT->CHANNEL[0].CVAL; //counts down
+ count = __count;
+ __enable_irq(); //END CRITICAL SECTION
+
//Convert to ticks
return (__rolloverValue - tick) + count * __rolloverValue;
}
@@ -69,7 +70,7 @@
}
void Timer_PIT::__stop_timer() {
- PIT->MCR |= PIT_MCR_MDIS_MASK; //Setting MDIS bit disables the timer.
+ PIT->CHANNEL[0].TCTRL &= ~PIT_TCTRL_TEN_MASK; //Disable the timer.
}
void Timer_PIT::__timer_isr() {
