EmbeddedRelated.com
Forums

PWM Problem

Started by vineet jain June 3, 2006
Hi all,
I am having difficulties with initiating the PWM. Here's the code to enable PWM4 single edge on LPC2104 at 11.0592 Mhz.

PINSEL0 = 0x00020000;
PWMPR = 0x7FF;
PWMPCR = 0x00001000;
PWMMCR = 0x00002000;
PWMMR0 = 0x00002000;
PWMMR4 = 0x00001000;
PWMLER = 0x00000010;
PWMTCR = 0x00000002;
PWMTCR = 0x00000009;
Anything I am missing.

Thanks in advance,
Vineet.
__________________________________________________



An Engineer's Guide to the LPC2100 Series

I think the problem is that you're using MR4 to reset the counter,
when you should be using MR0 for that.

Try PWMMCR = 0x00000002;

Regards,
Danish

--- In l..., vineet jain wrote:
>
> Hi all,
> I am having difficulties with initiating the PWM. Here's the code to enable PWM4 single
edge on LPC2104 at 11.0592 Mhz.
>
> PINSEL0 = 0x00020000;
> PWMPR = 0x7FF;
> PWMPCR = 0x00001000;
> PWMMCR = 0x00002000;
> PWMMR0 = 0x00002000;
> PWMMR4 = 0x00001000;
> PWMLER = 0x00000010;
> PWMTCR = 0x00000002;
> PWMTCR = 0x00000009;
> Anything I am missing.
>
> Thanks in advance,
> Vineet.
> __________________________________________________
>
>
>
>

Oh and PWMLER probably wants to be 0x00000009 once you've set
PWMMR0 and PWMMR4
- Danish
--- In l..., "Danish Ali" wrote:
>
> I think the problem is that you're using MR4 to reset the counter,
> when you should be using MR0 for that.
>
> Try PWMMCR = 0x00000002;
>
> Regards,
> Danish





Yes, rightly stated, i realized it that time. Anyways thanks. But the PWMLER value for PWMMR0 needn't be set since to change the PWM cycle I need to update the PWMMR4 value.

Thanks,
Vineet.

Danish Ali wrote: Oh and PWMLER probably wants to be 0x00000009 once you've set
PWMMR0 and PWMMR4
- Danish
--- In l..., "Danish Ali" wrote:
>
> I think the problem is that you're using MR4 to reset the counter,
> when you should be using MR0 for that.
>
> Try PWMMCR = 0x00000002;
>
> Regards,
> Danish

SPONSORED LINKS
Microcontrollers Microprocessor Intel microprocessors

---------------------------------
vineet jain wrote:

>Hi all,
> I am having difficulties with initiating the PWM. Here's the code to enable PWM4 single edge on LPC2104 at 11.0592 Mhz.
>
> PINSEL0 = 0x00020000;
> PWMPR = 0x7FF;
> PWMPCR = 0x00001000;
> PWMMCR = 0x00002000;
> PWMMR0 = 0x00002000;
> PWMMR4 = 0x00001000;
> PWMLER = 0x00000010;
> PWMTCR = 0x00000002;
> PWMTCR = 0x00000009;
>Anything I am missing.
>
>
>
Yes, you may have to enable the PWM0 in the PCON register. My code
started to work after I found it was turned off.

TomW

--
Tom Walsh - WN3L - Embedded Systems Consultant
http://openhardware.net, http://cyberiansoftware.com
"Windows? No thanks, I have work to do..."
----------------