Skip to content

Commit

Permalink
Merge pull request ARMmbed#3503 from CalSol/pwmfix
Browse files Browse the repository at this point in the history
[LPC15xx] Ensure that PWM=1 is resolved correctly
  • Loading branch information
sg- committed Jan 9, 2017
2 parents cefae22 + 9a8cd05 commit c305000
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion targets/TARGET_NXP/TARGET_LPC15XX/pwmout_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit c305000

Please sign in to comment.