Forums

PWM issue with LPC2366

Started by zvonkobharije September 2, 2008
I'm setting up PWM to make a simple AFSK modem. Though I think i'm
initializing PWM the right way, but there's no output. Here's the code:

PCONP |= PCONP_PCPWM1; // turn it on!

PCLKSEL1 &= ~(BIT(13) | BIT(12)); // pclk = cclk
PCLKSEL1 |= BIT(12);

PINSEL4 &= ~(BIT(1) | BIT(0)); // set GPIO P2.0 to PWM1.1
PINSEL4 |= BIT(0); // set GPIO P2.0 to PWM1.1

PWM1TCR = PWM1TCR_Counter_Reset;
PWM1MCR = PWM1MCR_PWMMR0R; // reset when MATCH0 register equals TC
PWM1PR = 0x00; /* count frequency:Fpclk */
PWM1MR0 = MODEM_PWM_1200HZ;
PWM1MR1 = MODEM_PWM_1200HZ / 2;
PWM1LER = PWM1LER_Enable_PWM_Match_0_Latch |
PWM1LER_Enable_PWM_Match_1_Latch;
// clear reset and enable PWM
PWM1PCR = PWM1PCR_PWMENA1;
PWM1TCR = PWM1TCR_PWM_Enable | PWM1TCR_Counter_Enable;
I think I'm missing something (trivial), but i've exhausted all my
ideas. Maybe someone has some better ideas than I have? ;)
Thanks,
Zvonko

An Engineer's Guide to the LPC2100 Series

Hi Zvonko:

The PWM setup seems to be ok (as long as the constants you use for the
registers settings are ok).

Have you tried to set up the P2.0 direction as output? This is not
shown on your code.
I have a two channel PWM working perfectly on P3.25 and P3.26, and I
define the ports as outputs (FIO3DIR)

Regards,

Alex R.

--- In l..., "zvonkobharije" wrote:
>
> I'm setting up PWM to make a simple AFSK modem. Though I think i'm
> initializing PWM the right way, but there's no output. Here's the code:
>
> PCONP |= PCONP_PCPWM1; // turn it on!
>
> PCLKSEL1 &= ~(BIT(13) | BIT(12)); // pclk = cclk
> PCLKSEL1 |= BIT(12);
>
> PINSEL4 &= ~(BIT(1) | BIT(0)); // set GPIO P2.0 to PWM1.1
> PINSEL4 |= BIT(0); // set GPIO P2.0 to PWM1.1
>
> PWM1TCR = PWM1TCR_Counter_Reset;
> PWM1MCR = PWM1MCR_PWMMR0R; // reset when MATCH0 register equals TC
> PWM1PR = 0x00; /* count frequency:Fpclk */
> PWM1MR0 = MODEM_PWM_1200HZ;
> PWM1MR1 = MODEM_PWM_1200HZ / 2;
> PWM1LER = PWM1LER_Enable_PWM_Match_0_Latch |
> PWM1LER_Enable_PWM_Match_1_Latch;
> // clear reset and enable PWM
> PWM1PCR = PWM1PCR_PWMENA1;
> PWM1TCR = PWM1TCR_PWM_Enable | PWM1TCR_Counter_Enable;
> I think I'm missing something (trivial), but i've exhausted all my
> ideas. Maybe someone has some better ideas than I have? ;)
> Thanks,
> Zvonko
>