mbed lib with startup delay fixed for Nucleo401RE

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Mon Apr 07 17:00:08 2014 +0100
Parent:
152:3248c4875353
Child:
154:be4113396fa5
Commit message:
Synchronized with git revision 2e32c71b50171aa1bc165d5e7b3281ab3e62ecd2

Full URL: https://github.com/mbedmicro/mbed/commit/2e32c71b50171aa1bc165d5e7b3281ab3e62ecd2/

Also changed pin assignment for the PWM test.

Changed in this revision

targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c	Mon Apr 07 16:45:06 2014 +0100
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/TARGET_K64F/pwmout_api.c	Mon Apr 07 17:00:08 2014 +0100
@@ -116,15 +116,19 @@
 }
 
 void pwmout_write(pwmout_t* obj, float value) {
+    uint32_t instance = obj->pwm_name >> TPM_SHIFT;
     if (value < 0.0f) {
         value = 0.0f;
     } else if (value > 1.0f) {
         value = 1.0f;
     }
-    uint16_t mod = ftm_hal_get_mod(obj->pwm_name >> TPM_SHIFT);
+    uint16_t mod = ftm_hal_get_mod(instance);
     uint32_t new_count = (uint32_t)((float)(mod) * value);
-    ftm_hal_set_channel_count_value(obj->pwm_name >> TPM_SHIFT, obj->pwm_name & 0xF, new_count);
-    ftm_hal_set_counter(obj->pwm_name >> TPM_SHIFT, 0);
+    // Stop FTM clock to ensure instant update of MOD register
+    ftm_hal_set_clock_source(instance, kClock_source_FTM_None);
+    ftm_hal_set_channel_count_value(instance, obj->pwm_name & 0xF, new_count);
+    ftm_hal_set_counter(instance, 0);
+    ftm_hal_set_clock_source(instance, kClock_source_FTM_SystemClk);
 }
 
 float pwmout_read(pwmout_t* obj) {