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: Berekenen_motorhoek Encoder System_Identification Motor_PID_set_parameters ... more
Fork of FastPWM by
Revision 32:ff245801a00d, committed 2016-10-17
- Comitter:
 - sjoerdbarts
 - Date:
 - Mon Oct 17 09:35:06 2016 +0000
 - Parent:
 - 31:10e2e171f430
 - Commit message:
 - -
 
Changed in this revision
| Device/FastPWM_KSDK.cpp | Show annotated file Show diff for this revision Revisions of this file | 
--- a/Device/FastPWM_KSDK.cpp	Tue Sep 06 20:17:21 2016 +0000
+++ b/Device/FastPWM_KSDK.cpp	Mon Oct 17 09:35:06 2016 +0000
@@ -1,7 +1,7 @@
 #if defined(TARGET_KPSDK_MCUS)
 
 #include "FastPWM.h"
-#include "fsl_ftm.h"
+#include "fsl_clock_manager.h"
 
 
 #define PWM_CNV              (*(((fastpwm_struct*)fast_obj)->CnV))  
@@ -15,16 +15,18 @@
 } fastpwm_struct;
 
 static uint32_t pwm_prescaler;
-static FTM_Type *const ftm_addrs[] = FTM_BASE_PTRS;
 
 void FastPWM::initFastPWM( void ) {
     fast_obj = new fastpwm_struct;
     bits = 16;
-
-    pwm_prescaler = SystemCoreClock / CLOCK_GetFreq(kCLOCK_BusClk);;
+    
+    uint32_t pwm_base_clock;
+    CLOCK_SYS_GetFreq(kBusClock, &pwm_base_clock);
+    pwm_prescaler = SystemCoreClock / pwm_base_clock;
 
-    unsigned int ch_n = (_pwm.pwm_name & 0xF);
-    FTM_Type *ftm = ftm_addrs[_pwm.pwm_name >> TPM_SHIFT];
+    uint32_t ftms[] = FTM_BASE_ADDRS;
+    unsigned int ch_n = (_pwm.pwm_name & 0xFF);
+    FTM_Type *ftm = (FTM_Type *)ftms[_pwm.pwm_name >> TPM_SHIFT];
     
     ((fastpwm_struct*)fast_obj)->CnV = &ftm->CONTROLS[ch_n].CnV;
     ((fastpwm_struct*)fast_obj)->MOD = &ftm->MOD;
@@ -33,10 +35,6 @@
 
 void FastPWM::pulsewidth_ticks( uint32_t ticks ) {
     PWM_CNV = ticks;
-    
-    //Temporary work around until I figure out which settings mbed screwed up in this update
-    FTM_Type *ftm = ftm_addrs[_pwm.pwm_name >> TPM_SHIFT];
-    FTM_SetSoftwareTrigger(ftm, true);
 }
 
 void FastPWM::period_ticks( uint32_t ticks ) {
    