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.
Dependents: qonly_controller foc-ed_in_the_bot_compact foc-ed_in_the_bot_compact CurrentModeSine ... more
Fork of FastPWM by
Revision 18:d91c0629e4e6, committed 2014-10-04
- Comitter:
- jocis
- Date:
- Sat Oct 04 20:54:56 2014 +0000
- Parent:
- 17:8378bc456f0d
- Child:
- 19:ba7a5bf634b3
- Commit message:
- Minor optimisation in updateTicks()
Changed in this revision
| FastPWM_common.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/FastPWM_common.cpp Sat Oct 04 13:14:44 2014 +0000
+++ b/FastPWM_common.cpp Sat Oct 04 20:54:56 2014 +0000
@@ -95,9 +95,9 @@
void FastPWM::updateTicks( uint32_t prescaler ) {
dticks = SystemCoreClock / (double)prescaler;
- dticks_us = SystemCoreClock / (double)prescaler / 1000000.0f;
- iticks_ms = SystemCoreClock / prescaler / 1000;
- iticks_us = SystemCoreClock / prescaler / 1000000;
+ dticks_us = dticks / 1000000.0f;
+ iticks_us = (int)(dticks_us + 0.5);
+ iticks_ms = (int)(dticks_us * 1000.0 + 0.5);
}
int FastPWM::calcPrescaler(uint64_t clocks) {
