void PWMB_init(void)
{
LPC_SYSCON->SYSAHBCLKCTRL |= (1<<10); //enable TMR32B1 clk
// enable PWM on MAT 0, 1, 2
LPC_TMR32B1->PWMC = 0x07;
// Set pin MAT0 as PWM
LPC_IOCON->R_PIO1_1 &= ~0x07;
LPC_IOCON->R_PIO1_1 |= 0x03;
// Set pin MAT1 as PWM
LPC_IOCON->R_PIO1_2 &= ~0x07;
LPC_IOCON->R_PIO1_2 |= 0x03;
// Set pin MAT2 as PWM
LPC_IOCON->SWDIO_PIO1_3 &= ~0x07;
LPC_IOCON->SWDIO_PIO1_3 |= 0x03;
// Set PWM Cycle
LPC_TMR32B1->MR3= 255;
// Set PWM duty (0 -> 1) on each pin
LPC_TMR32B1->MR0 = 255;
LPC_TMR32B1->MR1 = 255;
LPC_TMR32B1->MR2= 255;
// Config Prescaler
LPC_TMR32B1->PR = 47;
// Config reset timer on MR3
LPC_TMR32B1->MCR = (1<<10);
// Reset and enable timer
LPC_TMR32B1->TCR = 3;
LPC_TMR32B1->TCR = 1;
}