Hi @xiangjun_rong,
Using MASK Register, solve a problem put not all. During the begining of code, the pin float and I get problem, after configuration using mask all work fine. I only release mask after calibration of sensor, so, I set mask to normal again, and start pwm.
I put my main code above. From begining of main until last line from example, the pin is floating, shorting the PS, is not so much time but I don't know if this going to be a problem.
BR,
Lucas Moraes
void main (void)
{
/* initialise SYS module */
ioctl(SYS, SYS_INIT, NULL);
/* configure COP module */
ioctl(COP, COP_INIT, NULL);
/* configure all GPIO modules */
ioctl(GPIO, GPIO_INIT_ALL, NULL);
// /* initialize ADC module (sequential ANA0, 5-7, ANB4-7, SW triggered ) */
// ioctl(ADC, ADC_INIT, NULL);
/* configure PWM module */
//ioctl(EFPWM_A, EFPWM_INIT, NULL);
/* DAC_A generates /\/\/\ signal on DAC_A output DACO */
// ioctl(DAC_A, DAC_INIT, NULL);
// /* XBAR interconnects the synchronization signal from QT_A0 to DAC_A */
// ioctl(XBAR_A, XBAR_A_INIT, NULL);
/*
* TODO: put your other module initialisation calls here
* e.g. ioctl(SCI, SCI_INIT, NULL)
*
*/
/* initialise interrupt controller and enable interrupts */
ioctl(INTC, INTC_INIT, NULL);
archEnableInt();
// -----------------------------------------------------
// CS init Config
// -----------------------------------------------------
CSc = initCS(FRAC16(0.2));
// -----------------------------------------------------
// Current Sensor ACS init Config
// -----------------------------------------------------
CurrSensor = initACS712(MODEL_ACS712_05A,false);
// -----------------------------------------------------
// DAC init Config
// -----------------------------------------------------
DAC1 = initDAC_ctrl(DAC_A,true,1024);
// -----------------------------------------------------
// Clock gate Config
// -----------------------------------------------------
bitWrite(SIM->sim_pce3,7,1,0b1);
bitWrite(SIM->sim_pce3,6,1,0b1);
bitWrite(SIM->sim_pce3,5,1,0b1);
// -----------------------------------------------------
// LED Config
// -----------------------------------------------------
LED1 = initLEDctrl(GPIO_F, 8,true);
LED2 = initLEDctrl(GPIO_F, 9,true);
LED3 = initLEDctrl(GPIO_F,10,true);
LED4 = initLEDctrl(GPIO_F,11,true);
LED5 = initLEDctrl(GPIO_G,5,true);
// -----------------------------------------------------
// GPIO Config
// -----------------------------------------------------
IP_RESET = initGPIOctrl(GPIO_G,6,true,GPIO_OUTPUT);
IP_FAULT = initGPIOctrl(GPIO_G,7,false,GPIO_INPUT);
IP_MAINS = initGPIOctrl(GPIO_G,8,false,GPIO_OUTPUT);
BT_TEST = initGPIOctrl(GPIO_C,4,false,GPIO_INPUT);
// -----------------------------------------------------
// PWM Config
// -----------------------------------------------------
PWMSyncPWM1 = initPWMSynchroConfig_PWM1();
PWMSyncPWM2 = initPWMSynchroConfig_PWM2();
PWMOutPWM1_2 = initPWMOutputConfig_PWM1();
PWMGeneralPWM1 = initPWMGeneralConfig_PWM1();
PWMGeneralPWM2 = initPWMGeneralConfig_PWM2();
PWMFIPWM1_2 = initPWMForceInitConfig_PWM1();
PWM1 = initPWMctrl(GPIO_E,0,EFPWM_A,0,&PWMSyncPWM1,&PWMGeneralPWM1,
&PWMOutPWM1_2,&PWMFIPWM1_2,false);
PWM2 = initPWMctrl(GPIO_E,2,EFPWM_A,1,&PWMSyncPWM2,&PWMGeneralPWM2,
&PWMOutPWM1_2,&PWMFIPWM1_2,false);
PWMctrl_setCounterPWMA(true,true,false,false);
PWMctrl_sendLDOKPWMA(true,true,false,false);