winnie 发表于 2009-3-13 14:32:54

dsPIC30F2010的PWM启动不起来

void pwm_init()
{
_TRISE0 = 0;
_TRISE1 = 0;
_LATE0 = 0;
_LATE1 = 0;
OC1CON = 0X0000;
T2CON = 0x0000;
TMR2 = 0x0fff;
OC1RS = 0X0800;//占空比
PR1 = 0X0FFF;   //PWM周期值
_PMOD1 = 1; //使用PWM1为独立输出
_PEN1H = 1; //PWM1高为PWM输出
_PEN1L = 1; //PWM1低也为输出
PDC1 = 0X0800;   //PWM占空比
_T2IP = 7;
_T2IE = 1;
_PWMIF = 0;
_PWMIE = 0;
_T2IF = 0;
T2CONbits.TON = 1;
OC1CONbits.OCM = 6;
}

winnie 发表于 2009-3-13 14:33:26

2010有专门的PWM模块
或者把所有中断允许位都关了试试
页: [1]
查看完整版本: dsPIC30F2010的PWM启动不起来