lpcware

LPC11C24 PWM RGB control issue.

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by hetii on Thu Jun 12 04:55:30 MST 2014
Hello :)

I try control RGB led by lpc11c24 (crystal 12MHz).


static void timer16PWMInit()
{
//enable CT16B0_MAT1
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_8, (IOCON_FUNC2 | IOCON_MODE_PULLUP));  //MAT0 = B
Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_9, (IOCON_FUNC2 | IOCON_MODE_PULLUP));  //MAT1 = R
//Chip_IOCON_PinMuxSet(LPC_IOCON, IOCON_PIO0_11, (IOCON_FUNC2 | IOCON_MODE_PULLUP)); //MAT3 = G //Will be another timer.

Chip_TIMER_Init(LPC_TIMER16_0); //enable timer 0
Chip_TIMER_PrescaleSet(LPC_TIMER16_0, 72-1);               //PR - prescaler:72 = time base 1µs

Chip_TIMER_ResetOnMatchEnable(LPC_TIMER16_0, 2);    //MCR - MR2 reset
Chip_TIMER_SetMatch(LPC_TIMER16_0, 2, 10*1000);        //MR - Period for MR2 = 1ms*10 = 100Hz

Chip_TIMER_SetMatch(LPC_TIMER16_0, 0, 500);               //MR - Duty cycles for blue led
Chip_TIMER_SetMatch(LPC_TIMER16_0, 1, 50);               //MR - Duty cycles for red led

Chip_TIMER_CountWrite(LPC_TIMER16_0,(1<<0)|(1<<1));    //PWMC - enable PWM signal on MAT0 and MAT1

Chip_TIMER_Enable(LPC_TIMER16_0);         //TCR  - and run...
}


The code above works like I expect, the blue led shine stronger then red.

But when i toggle the duty cycles like that:

Chip_TIMER_SetMatch(LPC_TIMER16_0, 0, 50);   //MR - Duty cycles B
Chip_TIMER_SetMatch(LPC_TIMER16_0, 1, 500);  //MR - Duty cycles R


Only the red led shine:(

Also is it possible to use MAT2 also as a output for PWM signal and use some other register to reset my timmer (use all MATn from timer16_0 as output) ?

Regards.



Outcomes