From 9a8cd059f85535816dc83f1329c9b1becd42150d Mon Sep 17 00:00:00 2001 From: Richard Lin Date: Sat, 24 Dec 2016 23:17:16 -0800 Subject: [PATCH] Ensure that PWM=1 is resolved correctly --- targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c b/targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c index f9306dda24..5cda42115d 100644 --- a/targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c +++ b/targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c @@ -91,6 +91,9 @@ void pwmout_init(pwmout_t* obj, PinName pin) { pwm->OUT0_SET = (1 << 0); // event 0 pwm->OUT0_CLR = (1 << 1); // event 1 + // Resolve conflicts on output 0 to set output + // This allows duty cycle = 1.0 to work, where the MATCH registers for set and clear are equal + pwm->RES = 0x01; pwm->EV0_CTRL = (1 << 12); pwm->EV0_STATE = 0xFFFFFFFF; @@ -169,7 +172,7 @@ void pwmout_period_us(pwmout_t* obj, int us) { // Halt the timer and force the output low pwm->CTRL |= (1 << 2) | (1 << 3); pwm->OUTPUT = 0x00000000; - + // Ensure the new period will take immediate effect when the timer is un-halted pwm->MATCH0 = pwm->MATCHREL0; }