|
发表于 2014-3-7 09:43:45
|
显示全部楼层
LPC_SC->PCONP |=PCPWM1;
LPC_PINCON->PINSEL4 = (LPC_PINCON->PINSEL4&(~(3<<(2 * 5))))|(1<<(2 * 5));
LPC_PWM1->TCR =0X02;
LPC_PWM1->PR =0X00;
LPC_PWM1->MCR =0x03;
LPC_PWM1->MR0 =MotorStep.Cycle;
LPC_PWM1->MR6 =MotorStep.Cycle/2;
LPC_PWM1->LER =0X41;
//LPC_PWM1->PCR=0X4000;
//LPC_PWM1->TCR=0X09;
NVIC_SetPriority(PWM1_IRQn, 1);
NVIC_EnableIRQ(PWM1_IRQn);
void PWM6RunFunc(void)
{
LPC_PWM1->TCR =0X02;
PWM_Set(MotorStep.Cycle);
PWM_Start();
}
void PWM_Set( uint32 cycle )
{
LPC_PWM1->MR0 = cycle;
LPC_PWM1->MR6 = cycle/2;
LPC_PWM1->LER = 0x41;
}
void PWM_Start( void )
{
LPC_PWM1->PCR =0X4000;
LPC_PWM1->TCR =0X09;
}
void PWM_Stop( void)
{
LPC_PWM1->PCR = 0;
LPC_PWM1->TCR = 0x00; /* Stop all PWMs */
} |
|