你好,我想使用PWM故障3。我的PWM代码是工作的,但故障3针是3.3,当它没有故障3。
以上来自于百度翻译
以下为原文
hi,
I want to use pwm fault3 . My pwm code is work but Fault 3 pin is 3.3 when it didn't fault 3 .
this code :
PTCONbits.PTEN =0;
// ~~~~~~~~~~~~~~~~~~~~~~ PWM1 Configura
tion ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
IOCON2bits.PENH = 0; // PWM1H is controlled by PWM module
IOCON2bits.PENL = 0;
IOCON3bits.PENH = 0; // PWM1H is controlled by PWM module
IOCON3bits.PENL = 0;
IOCON1bits.PENH = 1; // PWM1H is controlled by PWM module
IOCON1bits.PENL = 1; // PWM1L is controlled by PWM module
IOCON1bits.PMOD = 0; // Select Complementary Output PWM mode
PWMCON1bits.ITB = 1; // PHASE1 provides the PWM time period value
PWMCON1bits.CAM = 1; // Center-Aligned Mode
PHASE1 = PWM1_PERIOD_VALUE;
ALTDTR1 = PWM1_DEADTIME_VALUE;
PDC1 = PWM1_INITIAL_VALUE;
FCLCON1bits.FLTMOD = 3; //fault mode is disabled
PTCON2 = 0;
// FAULT
FCLCON1bits.FLTMOD = 1; // PWM generator pins for FLTDAT values (cycle-by-cycle condition)
FCLCON1bits.IFLTMOD = 0; // Normal Fault Mode
FCLCON1bits.FLTSRC = 9; // Select fault source FLT3,
FCLCON1bits.FLTPOL = 0; // Fault input pin is set to active-low ////////
IOCON1bits.FLTDAT = 0; // Shuts down PWM1L and PWM1H signals to inactive state
PWMCON1bits.FLTIEN = 1; /* Enable fault interrupt */
TRIG1 = 0; //Point at which the ADC module is to be triggered by primary PWM
TRGCON1bits.TRGDIV = 0; // Trigger output divider set to trigger ADC on every trigger match event
TRGCON1bits.TRGSTRT = 0; // First ADC trigger event occurs after ONE trigger match events
PTCONbits.PTEN = 1;