Forums

PWM on LPC2103 w/o interrupt

Started by "r. w." October 12, 2006
Hello,

I try to implement on the LPC2103 a PWM with the auxiliary match
register 3 as recommended in the user manual. But I do not want to use
an interrupt routine for that. How can this done?
Does anybody have an example which can be shared or "a more detailed
how to"?
Thank you
..richard

An Engineer's Guide to the LPC2100 Series

r. w. wrote:
> Hello,
>
> I try to implement on the LPC2103 a PWM with the auxiliary match
> register 3 as recommended in the user manual. But I do not want to use
> an interrupt routine for that. How can this done?
> Does anybody have an example which can be shared or "a more detailed
> how to"?
>
If you set the External Match Control to toggle External Match [11:4],
then you would need to set Match Control Register to Reset TC when MRx
matches TC. The only downside is TC is common to all the match registers.
Joel
--- In l..., "r. w." wrote:
>
> Hello,
>
> I try to implement on the LPC2103 a PWM with the auxiliary match
> register 3 as recommended in the user manual. But I do not want to
use
> an interrupt routine for that. How can this done?
> Does anybody have an example which can be shared or "a more
detailed
> how to"?
> Thank you
> ..richard
>
here is the code I am using. It is for Timer1 but it is of course
the same with Timer 3. Match 0 is used to set the period (T1MR0 254), then you can use the 3 other match as PWM outputs. you have to
be aware than writing T1MR1 = 255 will give you a duty cycle of 0%
while T1MR1 = 0 will be 100%.

Hope this help
Gaetan
T1PR = 5; //LOAD THE PRESCALER to 15 --> timer2 runs
at 15MHz/5 = 3MHz
T1PC = 0; //RESET PRESCALE COUNTER
T1TC = 0; //RESET TIMER.
T1MR0 = 254; //PERIOD OF THE PWM OUTPUTS --> 3MHz/255 =~10KHz
T1MCR = 0x00000002; // RESET ON MR0 MATCHING TC
T1PWMCON = 0x0000000F; // //Enable PWM mode for MAT1.0, MAT1.1,
MAT1.2 AND MAT1.3

T1TCR = 0x01; //START COUNTER
Thank you gaetanbarthelemy, that helped. Now it works

PINSEL0 = (1<<11); //port 0.5
T0PWMCON = 0x2; // enable PWM mode on MR1
T0MR3 = 225; // MR3 period
T0MR1 = 140; // 39%
T0MCR = (1<<10); // MR3 reset
T0TCR = 0x1; // enable timer 0 counter
--- In l..., "gaetanbarthelemy"
wrote:
>
> --- In l..., "r. w." wrote:
> >
> > Hello,
> >
> > I try to implement on the LPC2103 a PWM with the auxiliary match
> > register 3 as recommended in the user manual. But I do not want to
> use
> > an interrupt routine for that. How can this done?
> > Does anybody have an example which can be shared or "a more
> detailed
> > how to"?
> > Thank you
> > ..richard
> >
> here is the code I am using. It is for Timer1 but it is of course
> the same with Timer 3. Match 0 is used to set the period (T1MR0 > 254), then you can use the 3 other match as PWM outputs. you have to
> be aware than writing T1MR1 = 255 will give you a duty cycle of 0%
> while T1MR1 = 0 will be 100%.
>
> Hope this help
> Gaetan
> T1PR = 5; //LOAD THE PRESCALER to 15 --> timer2 runs
> at 15MHz/5 = 3MHz
> T1PC = 0; //RESET PRESCALE COUNTER
> T1TC = 0; //RESET TIMER.
> T1MR0 = 254; //PERIOD OF THE PWM OUTPUTS --> 3MHz/255 =~10KHz
> T1MCR = 0x00000002; // RESET ON MR0 MATCHING TC
> T1PWMCON = 0x0000000F; // //Enable PWM mode for MAT1.0, MAT1.1,
> MAT1.2 AND MAT1.3
>
> T1TCR = 0x01; //START COUNTER
>