dsPIC33EP64MC502 PWM无输出
void PWM_Init(void)
{
PTCONbits.PTEN=0;
PTCONbits.PTSIDL=0;
PTCONbits.SESTAT=0;
PTCONbits.SEIEN=0;
PTCONbits.EIPU=0;
PTCONbits.SYNCPOL=0;
PTCONbits.SYNCOEN=0;
PTCONbits.SYNCEN=0;
PTCONbits.SYNCSRC=1;
PTCONbits.SEVTPS=0;
/* 1:1 Prescaler */
PTCON2bits.PCLKDIV=0; //120M
/* PTPER provides the PWM time period value */
PWMCON1bits.ITB=0;
PWMCON1bits.MDCS=0; //set PDCX as pwm duty
PWMCON1bits.DTC=2; //disable Dead Zone
PWMCON1bits.CAM=0; //Edge-Aligned mode
IOCON1bits.PENH=1; //PWM LOCK DISENABLE
IOCON1bits.PENL=1; //
IOCON1bits.SWAP=0;
/* Set PWM Period on Primary Time Base */
PTPER = 6000; //20khz 120M/20K=6000
/* Set Phase Shift */
PHASE1 = 0;
/* Set Duty Cycles */
PDC1 = 3000; //120M/20K*DUTY=6000*(0~1);
ANSELB = 0;
TRISBbits.TRISB14 = 0;
TRISBbits.TRISB15 = 0; //PWMH PWML as output
/* Enable PWM Module */
PTCONbits.PTEN=1;
}
用示波器测量PWM1H与PWM1L均无波形。请帮忙看下,不胜感激! |