Actually, i needed to stop the counter when changing the PWMMR4 value.
So, stop the counter, change the value and start it back again. It works.
Thanks anyways,
Vineet.
vineet jain wrote: Hi again,
I mean, why use the timer when you have PWM hardware support on LPC2104.
In any case, here is what i am trying to do:
main:
for (i=0;i<0x2000;i+=100)
{
PWMMR4 = i;
delay();
}
void PWM_init()
{
PINSEL0 = 0x00020000; // select PWM 4
PWMPR = 0x0; // prescalar value = 256.
PWMPCR = 0x00001000; // select PWM 4 as single edge PWM and enable PWM4
output
PWMMCR = 0x00000002; // reset timer counter when equal to Match counter
value
PWMMR0 = 0x2000;
PWMMR4 = 0x1; // This register value has to be changed at run time
for various colour shades.
PWMLER = 0x00000010;
PWMTCR = 0x00000002; // PWM Timer counter and Prescale counter synch.
reset.
PWMTCR = 0x00000009; // Enable PWM and counters are ready to count.
}
In this code, i am trying to increase the brightness gradually, giving a small
delay....to start with.
Hope this info is sufficient.
Vineet.
Ed Schlunder wrote: --- In l...,
vineet jain wrote:
> I was able to initiate the PWM. Now, how do I change the PWM edge
position during run time? I am using PWM4.
>
> I was changing the value of PWMMR4 keeping it within limits
specified by PWMMR0. But the LED connected does not change the shade?
Without seeing the code, I do not know what could be wrong.
While working on my TRAXMOD MOD player project, I originally wrote
some example code that does what you are trying to do. The firmware
sets up the P0.8 and P0.9 pins as 10-bit PWM outputs, and then fades
LEDs in and out using the PWM in an interrupt handler controlled by
timer 3. This was done on an LPC2103.
Hi again,
I mean, why use the timer when you have PWM hardware support on LPC2104.
In any case, here is what i am trying to do:
main:
for (i=0;i<0x2000;i+0)
{
PWMMR4 = i;
delay();
}
void PWM_init()
{
PINSEL0 = 0x00020000; // select PWM 4
PWMPR = 0x0; // prescalar value = 256.
PWMPCR = 0x00001000; // select PWM 4 as single edge PWM and enable PWM4
output
PWMMCR = 0x00000002; // reset timer counter when equal to Match counter
value
PWMMR0 = 0x2000;
PWMMR4 = 0x1; // This register value has to be changed at run time
for various colour shades.
PWMLER = 0x00000010;
PWMTCR = 0x00000002; // PWM Timer counter and Prescale counter synch.
reset.
PWMTCR = 0x00000009; // Enable PWM and counters are ready to count.
}
In this code, i am trying to increase the brightness gradually, giving a small
delay....to start with.
Hope this info is sufficient.
Vineet.
Ed Schlunder wrote: --- In l...,
vineet jain wrote:
> I was able to initiate the PWM. Now, how do I change the PWM edge
position during run time? I am using PWM4.
>
> I was changing the value of PWMMR4 keeping it within limits
specified by PWMMR0. But the LED connected does not change the shade?
Without seeing the code, I do not know what could be wrong.
While working on my TRAXMOD MOD player project, I originally wrote
some example code that does what you are trying to do. The firmware
sets up the P0.8 and P0.9 pins as 10-bit PWM outputs, and then fades
LEDs in and out using the PWM in an interrupt handler controlled by
timer 3. This was done on an LPC2103.
> I was able to initiate the PWM. Now, how do I
change the PWM edge position during run time? I am using PWM4. >
> I was changing the value of PWMMR4 keeping it within limits specified by PWMMR0. But the LED connected does not change the shade?
Without seeing the code, I do not know what could be wrong.
While working on my TRAXMOD MOD player project, I originally wrote
some example code that does what you are trying to do. The firmware
sets up the P0.8 and P0.9 pins as 10-bit PWM outputs, and then fades
LEDs in and out using the PWM in an interrupt handler controlled by
timer 3. This was done on an LPC2103.