lpcware

LPC824 pwm polarity bug

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by atilla grammer on Wed Feb 25 04:18:33 MST 2015
I have an application where a button interrupt adjusts my PWM duty cycle, and systick interrupt which turns PWM on and off. Here is how they look:


void PININT7_IRQHandler(void)
{
Chip_PININT_ClearIntStatus(LPC_PININT, PININTCH7);
out_dp += 5;
if(out_dp > 90 ) {
out_dp = 0;
}
DEBUGOUT("duty cycle: %d\r\n",out_dp);
}
void SysTick_Handler(void)
{
static int state = 0;

switch(state)
{
case 0:
Chip_SCTPWM_Start(SCT_PWM);
break;
case 1:
Chip_SCTPWM_Stop(SCT_PWM);
break;
default:
break;
}

state++;
state %= 5;
}



The problem is, once the duty cycle passes a certain threshold, the polarity of the PWM signal changes, and the signal becomes as shown in the attachment. For example, the threshold is ~70% when PWM frequency is 20kHz, and ~50% when the frequency is 15kHz, and this is doesn't happen at 10kHz. This only happens only if I stop and start the PWM after setting the duty cycle.

Did anyone notice similar behaviour on PWM?

Attachments

Outcomes