HELP LPC1768 PWM Problem

Status
Not open for further replies.

lee_lxw

Newbie level 5
Joined
Dec 3, 2012
Messages
8
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
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?
 
Last edited:

I have solve this problem.
My “LPC17xx.h” is not right.

typedef struct
{
__IO uint32_t IR;
__IO uint32_t TCR;
__IO uint32_t TC;
__IO uint32_t PR;
__IO uint32_t PC;
__IO uint32_t MCR;
__IO uint32_t MR0;
__IO uint32_t MR1;
__IO uint32_t MR2;
__IO uint32_t MR3;
__IO uint32_t CCR;
__I uint32_t CR0;
__I uint32_t CR1;
__I uint32_t CR2;
__I uint32_t CR3;
uint32_t RESERVED0; //hERE it was lost before
__IO uint32_t MR4;
__IO uint32_t MR5;
__IO uint32_t MR6;
__IO uint32_t PCR;
__IO uint32_t LER;
uint32_t RESERVED1[7];
__IO uint32_t CTCR;
} PWM_TypeDef;
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…