IC:dsPIC33EP128MC506
at First Stage(case "OutPul_Mode_PUL_NEG"),the code set PWM module working as "Redundant output mode" and set the "OVRDAT<1> provides data for output on PWMxH pin" and "OVRDAT<0> provides data for output on PWMxL pin" to close the PWM output , at this state ,if use this code as "IOCON1bits.OVRENH = 0; IOCON1bits.OVRENL = 0;" the PWM pulse will be appeared.
at second stage(case "OutPul_Mode_PUL_MIRR") ,the code will config the PWM module work as "Push-Pull mode", at this state ,if use this code as "IOCON1bits.OVRENH = 0; IOCON1bits.OVRENL = 0;" the PWM pulse will not be appeared.
what's wrong about this code?
Addtional Info: if the code run at debug mode ,just stop running and then restart, the PWM will apear correctly.
MCU Config Bits
// FOSCSEL
#pragma config FNOSC = FRCPLL // Oscillator Source Selection (Fast RC Oscillator with divide-by-N with PLL module (FRCPLL) )
#pragma config PWMLOCK = OFF // PWM Lock Enable bit (PWM registers may be written without key sequence)
#pragma config IESO = ON // Two-speed Oscillator Start-up Enable bit (Start up device with FRC, then switch to user-selected oscillator source)
this mean PWMIO will not be locked!
PWM initialize code
OpenHSPWM(PWM_MOD_DIS | PWM_IDLE_STOP | PWM_SEVT_INT_DIS | PWM_PER_UPDATE_IMM |
PWM_SEVT_OP_SCALE1, PWM_FRQ_DIVIC_NUM,
(unsigned int)(PWMB_Paras.Real_PWMBASE_Frq / INI_FRQ), //PTPER
0); //SEVTCMP
ConfigHSPWM1(PWM_FLT_INT_DIS | PWM_CL_INT_DIS | PWM_TRG_INT_EN |
PWM_TB_MODE_PER | PWM_D_CYLE_DC |
PWM_DT_DIS | PWM_HS_LL_DTCMP_0 | PWM_CENTER_ALIGN_DIS |
PWM_EXT_RES_DIS | PWM_PRI_TB | PWM_DC_UPDATE_IMM,
PWM_H_PIN_EN | PWM_L_PIN_EN | PWM_ORENH_OVRDAT |
PWM_ORENL_OVRDAT | PWM_PAIR_RED, //PWM_ORENH_OVRDAT_LL |
0, // PHASE value
PWM_TRIG_EVENT1 | PWM_TRIG_PS0,
0); // SPHASE value
ConfigHSPWMFault1(PWM_IND_FLT_DIS | PWM_CL_FLT32 | PWM_CL_SOURCE_HIGH |
PWM_CL_DIS | PWM_FLT_FLT32 | PWM_FLT_SOURCE_HIGH | PWM_FLT_DIS);
SetHSPWMDeadTime1(0,0);
SetHSPWMTrigCmp1(pdc1);
SetHSPWMDutyCycle1(pdc1);
/* PWM 2 */
ConfigHSPWM2(PWM_FLT_INT_DIS | PWM_CL_INT_DIS | PWM_TRG_INT_DIS |
PWM_TB_MODE_PER | PWM_D_CYLE_DC |
PWM_DT_DIS | PWM_HS_LL_DTCMP_0 | PWM_CENTER_ALIGN_DIS |
PWM_EXT_RES_DIS | PWM_PRI_TB | PWM_DC_UPDATE_IMM,
PWM_H_PIN_EN | PWM_L_PIN_EN | PWM_ORENH_OVRDAT | PWM_PIN_SWAP_EN |
PWM_ORENL_OVRDAT | PWM_PAIR_RED,
0, // PHASE value
PWM_TRIG_EVENT2 | PWM_TRIG_PS0,
0); // SPHASE value
ConfigHSPWMFault2(PWM_IND_FLT_DIS | PWM_CL_FLT32 | PWM_CL_SOURCE_HIGH |
PWM_CL_DIS | PWM_FLT_FLT32 | PWM_FLT_SOURCE_HIGH | PWM_FLT_DIS);
SetHSPWMDeadTime2(0, 0);
SetHSPWMTrigCmp2(0);
SetHSPWMDutyCycle2(pdc2);
the following code is used to change PWM woking mode
case OutPul_Mode_PUL_NEG:
IOCON1bits.PMOD = 0b01;
IOCON2bits.PMOD = 0b01;
break;
case OutPul_Mode_PUL_MIRR:
IOCON1bits.PMOD = 0b10;
IOCON2bits.PMOD = 0b10;
the following code is used to open PWM output
case OutPul_Mode_PUL_NEG:
IOCON1bits.OVRENL = 0;
IOCON2bits.OVRENH = 0;
break;
case OutPul_Mode_PUL_MIRR:
IOCON1bits.OVRENH = 0;
IOCON1bits.OVRENL = 0;
IOCON2bits.OVRENH = 0;
IOCON2bits.OVRENL = 0;
break;