Multiple PWM outputs?

Discussion created by lpcware Employee on Jun 15, 2016
Latest reply on Jun 15, 2016 by lpcware
Content originally posted in LPCWare by avass on Wed Jan 02 23:56:08 MST 2013

I would like to output two independent PWMs. For example, MAT0 outputing "0.1V" and MAT1 outputing "2.6V"...
I've been trying to use timer 0 using the init_timer16PWM / setMatch_timer16PWM functions outputing on 0_8/0_9 (MAT0/MAT1), but it looks like they are somehow interconnected. I am sure I don't know enough, I've been reading the docs, yet here I'm...

So far my code is :

LPC_TMR16B0->TCR = 0;//Disable Timer0

LPC_SYSCON->SYSAHBCLKCTRL |= (1<<7);// System AHB clock control enable clock to timer 0

LPC_TMR16B0->EMR = (1<<EMC3)|(0<<EMC2)|(1<<EMC1)|(1<<EMC0)|(1<<3)|(MATCH0)|(MATCH1);// Setup the external match register
LPC_IOCON->PIO0_8 &= ~0x07;
LPC_IOCON->PIO0_8 |= 0x02;// Timer0_16 MAT0
LPC_IOCON->PIO0_9 &= ~0x07;
LPC_IOCON->PIO0_9 |= 0x02;// Timer0_16 MAT1
LPC_TMR16B0->MR3 = 1000;// Setup the match registers
LPC_TMR16B0->MR0 = 0;// Match Register 0
LPC_TMR16B0->MR1 = 0;
LPC_TMR16B0->MCR = 1<<10;// Match Control Register : Reset on MR3
LPC_TMR16B0->PWMC = (1<<3)|0x02|0x01;// PWM Control Register Enable the selected PWMs and enable Match3
NVIC_EnableIRQ(TIMER_16_0_IRQn);// Enable the TIMER1 Interrupt

LPC_TMR16B0->MR0 = 50;
LPC_TMR16B0->MR1 = 500;

LPC_TMR16B0->TCR = 1;// Enable Timer16

I thought this would output 50/1000*3.3V on 0_8 and 500/1000*3.3V on 0_9, yet I'm getting 1.5V and 2.90Vs...

Can somebody please help.