Other Parts Discussed in Thread: UCD3138
Tool/software: TI C/C++ Compiler
I want to change duty cycle in pin DPWM0A, please help me to do this. Also, unable to implement dead time between pin DPWM0A and DPWM1A. I am including my program below, please help me to implement 40% duty cycle in pin DPWM0A, which is showing 50% now.
Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 0; //disable locally for init
Dpwm0Regs.DPWMCTRL0.bit.CLA_EN = 1; //default is 1 - use cla
Dpwm0Regs.DPWMCTRL0.bit.PWM_MODE = 0; //normal mode
Dpwm0Regs.DPWMPRD.all = PERIOD; //use .all for all values, make sure scaling matches.
Dpwm0Regs.DPWMEV1.all = PERIOD/2; //Put event 1 at start of period
Dpwm0Regs.DPWMEV2.all = (PERIOD * 3)/4; //1/4 of period - divide is OK because it's all constants.
Dpwm0Regs.DPWMEV3.all = 0;//1/2 of period
Dpwm0Regs.DPWMEV4.all = PERIOD/4; //3/4 of period
Dpwm0Regs.DPWMSAMPTRIG1.all = PERIOD; //3/4 of period
Dpwm0Regs.DPWMCTRL2.bit.SAMPLE_TRIG_1_EN = 1; //enable 1 sample trigger
Dpwm0Regs.DPWMCTRL1.bit.EVENT_UP_SEL = 1; //update at end of period
Dpwm0Regs.DPWMCTRL0.bit.PWM_EN = 1; //enable locally
Dpwm0Regs.DPWMCTRL2.bit.RESON_DEADTIME_COMP_EN = 1;
//Dpwm0Regs.DPWMPHASETRIG.bit.PHASE_TRIGGER = 2; //8nsec phase delay
Dpwm1Regs.DPWMCTRL0.bit.PWM_EN = 0; //disable locally for init
Dpwm1Regs.DPWMCTRL0.bit.CLA_EN = 1; //default is 1 - use cla
Dpwm1Regs.DPWMCTRL0.bit.PWM_MODE = 0; //normal mode
Dpwm1Regs.DPWMPRD.all = PERIOD; //use .all for all values, make sure scaling matches.
Dpwm1Regs.DPWMEV1.all = 0; //Put event 1 at start of period
Dpwm1Regs.DPWMEV2.all = PERIOD/4; //1/4 of period - divide is OK because it's all constants.
Dpwm1Regs.DPWMEV3.all = (PERIOD)/2; //1/2 of period
Dpwm1Regs.DPWMEV4.all = (PERIOD * 3)/4; //3/4 of period
Dpwm1Regs.DPWMSAMPTRIG1.all = PERIOD; //3/4 of period
Dpwm1Regs.DPWMCTRL2.bit.SAMPLE_TRIG_1_EN = 1; //enable 1 sample trigger
Dpwm1Regs.DPWMCTRL1.bit.EVENT_UP_SEL = 1; //update at end of period
Dpwm1Regs.DPWMCTRL0.bit.PWM_EN = 1; //enable locally
Dpwm1Regs.DPWMCTRL2.bit.RESON_DEADTIME_COMP_EN = 1;
//Dpwm1Regs.DPWMPHASETRIG.bit.PHASE_TRIGGER = 2; //8nsec phase delay