lee_lxw
Newbie level 5
- Joined
- Dec 3, 2012
- Messages
- 8
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,341
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 */
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 */
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: