LPC1549, PWM on SCT0_7

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

LPC1549, PWM on SCT0_7

1,109 Views
jørgenbusch
Contributor I

Hi,

I'm having trouble getting a PWM signal on PIO1_14 (for SCT0_7)

Maybe it the some clock issue, however I'm not sure. I hope you might have a hint of somekind.

Below is code (as you can see it is using the library from lpc chip. )

Using embOS as operating system.

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

#define SCT_PWM            LPC_SCT0 /* Use SCT0 for PWM */

#define SCT_PWM_PIN_OUT    7        /* COUT0_7 Generate square wave */

#define SCT_PWM_OUT 0

void Init_and_start_PWM(void)

{

Chip_SYSCTL_PowerDown(SYSCTL_POWERDOWN_SCTPLL_PD);
Chip_Clock_SetSCTPLLSource(SYSCTL_PLLCLKSRC_MAINOSC);
Chip_Clock_SetupSCTPLL(5,2);
Chip_SYSCTL_PowerUp(SYSCTL_POWERDOWN_SCTPLL_PD);
/* Wait for PLL to lock */
while (!Chip_Clock_IsSCTPLLLocked()) {}

#define SCT_PWM_RATE   200000        /* PWM frequency 200 KHz */

  Chip_SCTPWM_Init(LPC_SCT0);

Chip_SCTPWM_SetRate(LPC_SCT0, SCT_PWM_RATE);
/* Enable SWM clock before altering SWM */
Chip_Clock_EnablePeriphClock(SYSCTL_CLOCK_SWM);

  Chip_SWM_EnableFixedPin(SWM_FIXED_SCT0_OUT7);

  Chip_Clock_DisablePeriphClock(SYSCTL_CLOCK_SWM);

Chip_SCTPWM_SetOutPin(LPC_SCT0, SCT_PWM_OUT, SCT_PWM_PIN_OUT);

/* Start with 50% duty cycle */
Chip_SCTPWM_SetDutyCycle(LPC_SCT0, SCT_PWM_OUT, Chip_SCTPWM_PercentageToTicks(LPC_SCT0, 50));
Chip_SCTPWM_Start(LPC_SCT0);

----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------

Starting the PWM (just above), I only measure the pin goes high, and there it stays. Breaking the code shows that the counters are running in SCT.

BR Jørgen Busch

Labels (4)
Tags (4)
0 Kudos
Reply
1 Reply

783 Views
jørgenbusch
Contributor I

The define SCT_PWN_OUT cannot be 0, it must be fx, 1.

Then it runs :-)

Chip_SCTPWM_SetOutPin(LPC_SCT0, SCT_PWM_OUT, SCT_PWM_PIN_OUT);

/* Start with 50% duty cycle */
Chip_SCTPWM_SetDutyCycle(LPC_SCT0, SCT_PWM_OUT, Chip_SCTPWM_PercentageToTicks(LPC_SCT0, 50));

0 Kudos
Reply