lpcware

LPC824 PWM duty cycle 0% -> pin 'high' for one tick?

Discussion created by lpcware Employee on Jun 15, 2016
Content originally posted in LPCWare by Ralf C. on Fri May 22 03:03:04 MST 2015
Hi, i tried to copy a pwm example for the OM13071 board with the lpc824, but i fail to configure the pwm pin for a 0% duty cycle. I use the code below, but when i measure the output pin, it goes high for about 40ns.
It works somehow correct for duty cycles > 0.
What am i missing?
Anyway, is it possible to switch back the pin back to normal gpio mode?

i used the supplied lib-package lpc_chip_82x

Thanks in advance for any idea/hint (:



#define SCT_PWM           LPC_SCT
#define SCT_PWM_RATE100000
#define TICKRATE_HZ1000

void init(void)
{
/* Enable SWM clock before altering SWM */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

Chip_SWM_MovablePinAssign(SWM_SCT_OUT1_O, 18);

/* Initialize the SCT as PWM and set frequency */
Chip_SCTPWM_Init(SCT_PWM);
Chip_SCTPWM_SetRate(SCT_PWM, SCT_PWM_RATE);

/* Use SCT0_OUT1 pin */
Chip_SCTPWM_SetOutPin(SCT_PWM, 1, 1);

/* Start with 0% duty cycle */
Chip_SCTPWM_SetDutyCycle(SCT_PWM, 1, 0);
Chip_SCTPWM_Start(SCT_PWM);
}

Outcomes