mbed w/ spi bug fig

Dependents:   display-puck

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Jun 24 08:00:08 2014 +0100
Parent:
235:685d5f11838f
Child:
237:f3da66175598
Commit message:
Synchronized with git revision 31fd3f122572b5dd8476641f50e1b1d9b475a63b

Full URL: https://github.com/mbedmicro/mbed/commit/31fd3f122572b5dd8476641f50e1b1d9b475a63b/

[LPC1549] Enable present tests for the LPC1549

Changed in this revision

targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c	Mon Jun 23 14:00:09 2014 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC11XX_11CXX/pwmout_api.c	Tue Jun 24 08:00:08 2014 +0100
@@ -109,11 +109,15 @@
     } else if (value > 1.0f) {
         value = 1.0;
     }
-    
+
     timer_mr tid = pwm_timer_map[obj->pwm];
     LPC_TMR_TypeDef *timer = Timers[tid.timer];
     uint32_t t_off = timer->MR3 - (uint32_t)((float)(timer->MR3) * value);
-    
+    // to avoid spike pulse when duty is 0%
+    if (value == 0) {
+        t_off++;
+    }
+
     timer->TCR = TCR_RESET;
     timer->MR[tid.mr] = t_off;
     timer->TCR = TCR_CNT_EN;
@@ -124,6 +128,9 @@
     LPC_TMR_TypeDef *timer = Timers[tid.timer];
     
     float v = (float)(timer->MR3 - timer->MR[tid.mr]) / (float)(timer->MR3);
+    if (timer->MR[tid.mr] > timer->MR3) {
+        v = 0.0f;
+    }
     return (v > 1.0f) ? (1.0f) : (v);
 }