MC53F83XXX PWM

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

MC53F83XXX PWM

1,129 Views
lucasmoraeseng
Contributor II

Hi Everyone!

I'm working with MC53F83XXX (Mc53F83789) using the EVK board and I don't how to set properly the PWM and ADC to my application.

1) I have a current sensor in my ADC and I must start my code "calibrating" the 0 value from adc, but as my ADC is sync with my PWM, I use the PWM reload interruption to read the ADC channel. Is any way to start the PWM without change pin state?

2) I tried to use the OutputEnable function (OUTEN), but didn't work. This shows me that, when the code is debugging, before I set output enable to true, the pin is floating (about 1.34V), causing a false switching in my power module and a short circuit on my power supply. I'd like that this pin going to low in this case, but I don't how to do that.

 

Follow my code to configure PWM (I'm using a code to set everything to variables and after I write on registers, at this moment, everything on this is right):

 

 

 

PWMForceInit initPWMForceInitConfig_PWM1()
{
	PWMForceInit PWMfi;
	
	PWMfi.PwmFI23Out  = PWM_FI_23_OUT_PWM23;
	PWMfi.PwmFI23Level = false;

	PWMfi.PwmFI45Out  = PWM_FI_45_OUT_PWM45;
	PWMfi.PwmFI45Level = false;
	
	PWMfi.PWMFI23Enable = true;
	PWMfi.PWMFI45Enable = true;
	PWMfi.PWMFIXEnable = false;
		
	return PWMfi;
}

PWMOutput initPWMOutputConfig_PWM1()
{
	PWMOutput PWMOut;
	
	PWMOut.PWMAMaskOutput = PWM_MASK_OUTPUT_NORMAL;
	PWMOut.PWMBMaskOutput = PWM_MASK_OUTPUT_NORMAL;
	PWMOut.PWMXMaskOutput = PWM_MASK_OUTPUT_NORMAL;
	
	PWMOut.PWMAPolarity = PWM_POLARITY_ACTIVE_HIGH;
	PWMOut.PWMBPolarity = PWM_POLARITY_ACTIVE_HIGH;
	PWMOut.PWMXPolarity = PWM_POLARITY_ACTIVE_HIGH;
	
	PWMOut.PWMAOutputEn = true;
	PWMOut.PWMBOutputEn = true;
	PWMOut.PWMXOutputEn = false;
	
	return PWMOut;
}

PWMSynchro initPWMSynchroConfig_PWM1()
{
	PWMSynchro PWMSync;
	
	PWMSync.ReloadISR = true;
	PWMSync.ReloadErrorISR = false;
	PWMSync.MiddleCycleReloadEn = false;
	PWMSync.FullCycleReloadEn = true;
	
	PWMSync.PwmReloadFreq = PWM_RELOAD_FREQ_EVERY_1;
	PWMSync.PwmReloadsrc=PWM_RELOAD_SRC_THIS;
	PWMSync.PwmSyncsrc=PWM_SYNC_SRC_LOCAL;
	
	return PWMSync;
}

PWMGeneral initPWMGeneralConfig_PWM1()
{
	PWMGeneral PWMGen;
	
	PWMGen.CntStart = -2500;
	PWMGen.CntMid = 0;
	PWMGen.CntEnd = 2499;
	
	PWMGen.Value_TurnHigh = 0;
	PWMGen.Value_TurnLow = 0;
	
	PWMGen.Deadtime = 20;
	
	PWMGen.TotalCount = PWMGen.CntEnd-PWMGen.CntStart;
	
	PWMGen.PwmChannelPair = PWM_CH_PAIR_OPERATION_COMPLEMENTARY;
	PWMGen.PwmCompMode = PWM_COMP_MODE_EQUAL_TO;
	
	PWMGen.EnableDoubleSwitch = false;
	PWMGen.PWMXDoubleSwitch = false;
	
	PWMGen.PWMClockEnable = true;
	PWMGen.PwmClockPrescaler = PWM_CLOCK_PRESCALER_1;
	PWMGen.PwmDeadtimesrc=PWM_DEADTIME_SRC_PWM23;
	PWMGen.PwmLoadMode = PWM_LOAD_MODE_END_CYCLE;
	
	PWMGen.DebugEn = false;
	PWMGen.WaitEn = false;	
	
	return PWMGen;
}

 

 

Tags (3)
0 Kudos
4 Replies

1,122 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Lucas,

I think this is a common design that you connect a pull-down resistor on the PWM output pins, after you disable the pin by setting the corresponding bits in Output Enable Register, the PWM pins will be in high impedance, with the pull-down resistor, the pin will be low.

If you have not the pull-down resistor, for your current case, I think you can use MASK register as a workaround, setting the mask bit, the PWM pin will be in LOW.

Hope it can help you

BR

XiangJun Rong

xiangjun_rong_0-1606447177544.png

 

0 Kudos

1,085 Views
lucasmoraeseng
Contributor II

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);

 

 

 

0 Kudos

1,069 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Lucas,

I have checked the pins assignment, all the PWM pins are multiplexed with GPIO pins, in default, the PWM pin are in GPIO input mode before you configure them as PWM pins, I suppose that the PWM pin will be LOW after Reset.

So this is the firmware procedure, pls initialize the PWM module, enable PWM output signals, during this time, the PWM pins are in GPIO input mode, with external pull-down resistors, the PWM pins are LOW. Then initialize the PWM as PWM function, the PWM pin will function as PWM.

Hope it can help you

BR

XiangJun rong

0 Kudos

1,119 Views
lucasmoraeseng
Contributor II

Hi XiangJun Rong,

I'm already using a pull-down, maybe the value isn't enough for application?

 

lucasmoraeseng_0-1606472961913.png

 

Anyway, I'll try to set mask bits to see if this solve my calibration problem.

 

BR

Lucas Moraes

 

0 Kudos