lee_lxw
Newbie level 5
![Newbie level 5](/styles/images/ranks/blevel2.gif)
This is my LPC1768 PWM init procedure.
I measure the output with oscillograph.
First the electric level is high and then is constant low.
Which place is wrong?
uint32_t PWM_Init(void)
{
PINCON -> PINSEL3 |= (1 << 5); /* set GPIO P1.18 for PWM1[1] output */
GPIO1-> FIODIR |= (1 << 18); /* GPIO P1.8 Output */
PWM1 -> TCR = 0x02; /* PWM1 Counter Reset */
PWM1 -> PR = 0x00; /* count frequency:Fpclk */
PWM1 -> MCR = 0x02; /* reset on PWMMR0, reset TC if PWM0 matches */
PWM1 -> PCR = 0x00; /* Set single edge output */
![QQ截图20121205210206.png QQ截图20121205210206.png](https://www.edaboard.com/data/attachments/26/26537-bd24e80103bdb1cdc8c1a7815ac4d70b.jpg)
PWM1 -> MR0 = 100; /* MR0 */
PWM1 -> MR1 = 50; /* MR1 */
PWM1 -> LER = 0x03; /* MR0 and MR1 Lock Enable */
PWM1 -> PCR = (1 << 9); /* Enable PWM1[1] output */
PWM1 -> TCR = 0x9; /* Enable TC and PWM mode */
return (TRUE);
}
I Debugging and commissioning.
I found PW1 PCR register is not right written.
I have pritscreen if you can see the image.
I had a test. When I modify the PCR register in debugging with the right value.There is a PWM output withch measure with oscillograph.
Why? Someone met?
I measure the output with oscillograph.
First the electric level is high and then is constant low.
Which place is wrong?
uint32_t PWM_Init(void)
{
PINCON -> PINSEL3 |= (1 << 5); /* set GPIO P1.18 for PWM1[1] output */
GPIO1-> FIODIR |= (1 << 18); /* GPIO P1.8 Output */
PWM1 -> TCR = 0x02; /* PWM1 Counter Reset */
PWM1 -> PR = 0x00; /* count frequency:Fpclk */
PWM1 -> MCR = 0x02; /* reset on PWMMR0, reset TC if PWM0 matches */
PWM1 -> PCR = 0x00; /* Set single edge output */
![QQ截图20121205210206.png QQ截图20121205210206.png](https://www.edaboard.com/data/attachments/26/26537-bd24e80103bdb1cdc8c1a7815ac4d70b.jpg)
PWM1 -> MR0 = 100; /* MR0 */
PWM1 -> MR1 = 50; /* MR1 */
PWM1 -> LER = 0x03; /* MR0 and MR1 Lock Enable */
PWM1 -> PCR = (1 << 9); /* Enable PWM1[1] output */
PWM1 -> TCR = 0x9; /* Enable TC and PWM mode */
return (TRUE);
}
I Debugging and commissioning.
I found PW1 PCR register is not right written.
I have pritscreen if you can see the image.
I had a test. When I modify the PCR register in debugging with the right value.There is a PWM output withch measure with oscillograph.
Why? Someone met?
Last edited: