Content originally posted in LPCWare by fduignan on Wed Dec 07 08:35:21 MST 2011
The sample motor control pwm code supplied with LPCXpresso has a mistake. The correction is shown below (file: mcpwm.c, Project: NXP LPC17xx Motor Control PWM example )
Corrected code:
void MCPWM_Init(void)
{
LPC_SC->PCONP |= 0x00020000; /* Turn On MCPWM PCLK */
/* P1.19~1.26, P1.28~29 as Motor Control PWM pins. */
LPC_PINCON->PINSEL3 &= ~(0xFFFF<<6);
// LPC_PINCON->PINSEL3 &= ~(0x5555<<6); // Does not make any sense
LPC_PINCON->PINSEL3 |= (0x5555<<6); // This is the correct way
LPC_PINCON->PINSEL3 &= ~(0x0F<<24);
// LPC_PINCON->PINSEL3 &= ~(0x05<<24); // Does not make any sense
LPC_PINCON->PINSEL3 |= (0x05<<24); // This is the correct way
return;
}