Skip to content

Commit c305000

Browse files
authored
Merge pull request #3503 from CalSol/pwmfix
[LPC15xx] Ensure that PWM=1 is resolved correctly
2 parents cefae22 + 9a8cd05 commit c305000

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,9 @@ void pwmout_init(pwmout_t* obj, PinName pin) {
9191

9292
pwm->OUT0_SET = (1 << 0); // event 0
9393
pwm->OUT0_CLR = (1 << 1); // event 1
94+
// Resolve conflicts on output 0 to set output
95+
// This allows duty cycle = 1.0 to work, where the MATCH registers for set and clear are equal
96+
pwm->RES = 0x01;
9497

9598
pwm->EV0_CTRL = (1 << 12);
9699
pwm->EV0_STATE = 0xFFFFFFFF;
@@ -169,7 +172,7 @@ void pwmout_period_us(pwmout_t* obj, int us) {
169172
// Halt the timer and force the output low
170173
pwm->CTRL |= (1 << 2) | (1 << 3);
171174
pwm->OUTPUT = 0x00000000;
172-
175+
173176
// Ensure the new period will take immediate effect when the timer is un-halted
174177
pwm->MATCH0 = pwm->MATCHREL0;
175178
}

0 commit comments

Comments
 (0)