can not output PWM pulse on LPC4078

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

can not output PWM pulse on LPC4078

436 Views
lpcware
NXP Employee
NXP Employee
Content originally posted in LPCWare by phuockal on Fri Aug 14 01:16:06 MST 2015
Dear friends, experts,

I am using LPC4078 and I want to output PWM frequency 1Khz at P3.25
I am using lpc_pwm library, as attached.

my code to setup PWM is:

void main ()
{
//pwm
PWM_TIMERCFG_Type configParameter;
PWM_ConfigStructInit(PWM_MODE_TIMER, &configParameter);
PWM_Init(PWM_1, PWM_MODE_TIMER, &configParameter);

//config port P3.25 as PWM1[2]
PINSEL_ConfigPin(3,25,2);
//config pwm as single edge operation
PWM_ChannelConfig(PWM_1, 2, PWM_CHANNEL_SINGLE_EDGE);
//config match
PWM_MATCHCFG_Type matchConfig;
matchConfig.IntOnMatch = DISABLE;
matchConfig.MatchChannel = 2;
matchConfig.ResetOnMatch = ENABLE;//change
matchConfig.StopOnMatch = DISABLE;
PWM_ConfigMatch(PWM_1, &matchConfig);

//set duty cycle
        //PWM_MatchUpdate(PWM_1, 0, 1000, PWM_MATCH_UPDATE_NEXT_RST);
PWM_MatchUpdate(PWM_1, 2, 10, PWM_MATCH_UPDATE_NEXT_RST);
//start PWM
PWM_Cmd(PWM_1, ENABLE);
        //PWM_CounterCmd(PWM_1, ENABLE);
//reset counter
        //PWM_ResetCounter(PWM_1);
//enable pwm output
PWM_ChannelCmd(PWM_1, 2, ENABLE);

         while(1)
         {
         }
}

I measured the output but it is always 3.3V. there are no pulse.
Any body can share me any example code of using PWM.
I always appreciate your help

Original Attachment has been moved to: lpc_pwm.c.zip

Original Attachment has been moved to: lpc_pwm.h.zip

Labels (1)
0 Kudos
0 Replies