我开发了一个简单的程序来在 dsPIC33EV256GM002 上产生 PWM 波形,但我无法禁用它。我使用了 PWM1 和 PWM2,我会在 PWM1L1 引脚(DIP 封装上的引脚 26)上生成 PWM 波形,将 PWM1H1(DIP 封装上的引脚 25)保持为数字 I/O。理论上PWM寄存器设置:IOCON1bits.PENL = 1;/* PWM1L 由 PWM 模块控制/IOCON1bits.PENH = 0; / PWM1H 由 GPIO 模块控制 */ 应该这样做,但是,使用示波器,我注意到 PWM1H1 引脚上的 PWM 波形具有相反的值(当 PWM1L 为 1 时 PWM1H 为 0,反之亦然)即使它应该是数字 I/ O。
你有没有发现类似的问题?
非常感谢您的帮助与合作
问候
我使用了以下代码:
TRISBbits.TRISB10 = 0; /* Set as a digital output */
TRISBbits.TRISB11 = 0; /* Set as a digital output */
TRISBbits.TRISB12 = 0; /* Set as a digital output */
TRISBbits.TRISB13 = 0; /* Set as a digital output */
TRISBbits.TRISB14 = 0; /* Set as a digital output */
TRISBbits.TRISB15 = 0; /* Set as a digital output */
LATBbits.LATB10 = 0; /* Set as a digital output */
LATBbits.LATB11 = 0; /* Set as a digital output */
LATBbits.LATB12 = 0; /* Set as a digital output */
LATBbits.LATB13 = 0; /* Set as a digital output */
LATBbits.LATB14 = 0; /* Set as a digital output */
LATBbits.LATB15 = 0; /* Set as a digital output */
PORTBbits.RB10=0;
PORTBbits.RB11=0;
PORTBbits.RB12=0;
PORTBbits.RB13=0;
PORTBbits.RB14=0;
PORTBbits.RB15=0;
PTPER = 4000;
/*~~~~~~~~~~ PWM1 Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
IOCON1bits.PENL = 1; /* PWM1L is controlled by PWM module */
IOCON1bits.PENH = 0; /* PWM1H is controlled by GPIO module */
IOCON1bits.PMOD = 0; /* Select Independent Output PWM mode */
PDC1 = 500; /* Initial Duty cycle */
DTR1 = 0; /* Deadtime setting */
ALTDTR1 = 0; /* Deadtime setting */
PHASE1 = 0; /* No phase shift */
/*~~~~~~~~~~~ PWM2 Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
IOCON2bits.PENH = 1; /* PWM2H is controlled by PWM module */
IOCON2bits.PENL = 0; /* PWM2L is controlled by GPIO module */
IOCON2bits.PMOD = 0; /* Select Independent Output PWM mode */
PDC2 = 2000; /* Initial Duty cycle */
DTR2 = 0; /* Deadtime setting */
ALTDTR2 = 0; /* Deadtime setting */
PHASE2 = 0; /* */
PTCONbits.PTEN = 1; /* Enable the PWM Module */