/* Configures 16-bit Timer 1 for PWM output using MR0 to control the period, and MR1, MR2 and MR3 for duty cycle. Duty cycle can be adjusted via timer16SetMatch.  */
void timer16SetPWM1(uint16_t period)
/* Configures 16-bit Timer 1 for PWM output using MR0 to control the period, and MR1, MR2 and MR3 for duty cycle. Duty cycle can be adjusted via timer16SetMatch.  */
void timer16SetPWM1(uint16_t period)
{
  timer16Disable(1);
  LPC_SYSCON->SYSAHBCLKCTRL |= (1<<8);
  LPC_CT16B1->EMR =  (1<<10) | (1<<8) | (1<<6) | (1<<4) |
                     (1<<0)  | (1<<1) | (1<<2) | (1<<3);
  LPC_CT16B1->PWMC = (1<<0)  | (1<<1) | (1<<2) | (1<<3);
  timer16SetMatch(1, 0, period);
  timer16SetMatch(1, 1, period / 2);
  timer16SetMatch(1, 2, period / 2);
  timer16SetMatch(1, 3, period / 2);
  LPC_CT16B1->MCR = 1 << 1;
}