Quantcast
Channel: Forums - Recent Threads
Viewing all articles
Browse latest Browse all 262198

UCD3138: Questions about the inline void frequency_switch(void) function in UCD3138 full-bridge hard-switch development board firmware

$
0
0

Part Number:UCD3138

Hello
I was recently learning UCD3138 full-bridge hard switch development board firmware
I met a problem
I am confused about the function inline void frequency_switch(void)

inline void frequency_switch(void)
{
if(peroid_new > peroid_old) //
//peroid_old = pmbus_dcdc_config[0].period;
//peroid_new = pmbus_dcdc_config[0].period;
{
pmbus_dcdc_config[0].period = peroid_old + 1;//
peroid_old ++;
configure_vout_ramp_rate();
configure_ton_rise();
init_dpwm0();
init_dpwm1();
configure_dpwm_timing();
LoopMuxRegs.PWMGLBPER.all = pmbus_dcdc_config[0].period;
Filter2Regs.FILTEROCLPHI.bit.OUTPUT_CLAMP_HIGH = pmbus_dcdc_config[0].period * 1; // 100% max dity
Filter2Regs.FILTEROCLPLO.bit.OUTPUT_CLAMP_LOW = pmbus_dcdc_config[0].period * 0.4;
Filter0Regs.FILTEROCLPHI.bit.OUTPUT_CLAMP_HIGH = (pmbus_dcdc_config[0].period >> 1) - 500; // clamp to 50% duty - 500 * 250ps
Filter1Regs.FILTEROCLPHI.bit.OUTPUT_CLAMP_HIGH = (pmbus_dcdc_config[0].period >> 1) - 500; // clamp to 50% duty - 500 * 250ps
LoopMuxRegs.FILTERKCOMPA.bit.KCOMP0 = (3 * pmbus_dcdc_config[0].period) >> 6;
LoopMuxRegs.FILTERKCOMPB.bit.KCOMP2 = pmbus_dcdc_config[0].period >> 4;//In 4ns
}

if(peroid_new < peroid_old)
{
pmbus_dcdc_config[0].period = peroid_old - 1;//
peroid_old --;
configure_vout_ramp_rate();
configure_ton_rise();
init_dpwm0();
init_dpwm1();
configure_dpwm_timing();
LoopMuxRegs.PWMGLBPER.all = pmbus_dcdc_config[0].period;
Filter2Regs.FILTEROCLPHI.bit.OUTPUT_CLAMP_HIGH = pmbus_dcdc_config[0].period * 1; // 100% max dity
Filter2Regs.FILTEROCLPLO.bit.OUTPUT_CLAMP_LOW = pmbus_dcdc_config[0].period * 0.4;
Filter0Regs.FILTEROCLPHI.bit.OUTPUT_CLAMP_HIGH = (pmbus_dcdc_config[0].period >> 1) - 500; // clamp to 50% duty - 500 * 250ps
Filter1Regs.FILTEROCLPHI.bit.OUTPUT_CLAMP_HIGH = (pmbus_dcdc_config[0].period >> 1) - 500; // clamp to 50% duty - 500 * 250ps
LoopMuxRegs.FILTERKCOMPA.bit.KCOMP0 = (3 * pmbus_dcdc_config[0].period) >> 6;
LoopMuxRegs.FILTERKCOMPB.bit.KCOMP2 = pmbus_dcdc_config[0].period >> 4;//In 4ns
}
}

I think that this function is used to change the switching period.

When the new cycle issued by the upper computer is larger than the old cycle, the cycle is increased.

When the new cycle issued by the upper computer is smaller than the old cycle, the cycle is reduced.

Increasing or decreasing the period is an increase or decrease of one unit, instead of directly increasing or decreasing to a new value. This kind of gradual change is better than mutation.

However, I don't understand why you use “if” statements in functions, not“ for” statements. I think that if the old cycle of the“ if” statement can only increase or decrease by 1 unit, it cannot be increased or decreased to a new period.

Do not know what I understand right? Or is there a function of loop addition and subtraction in the program, but I do not know where.


Thank you


Viewing all articles
Browse latest Browse all 262198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>