求以下代码的解释:不太理解以下的代码含义求高手指点
1 void Svpwm_CalcDuration函数中
i32Q15_InvVbus = Q27_BASE / i32Q12_Vbus;
i32T1 = ((((i32Q12_V1 * i32Q15_InvVbus + Q11_BASE) >> 12) * pstc->i32PeakCnt) >> 15);
i32T2 = ((((i32Q12_V2 * i32Q15_InvVbus + Q11_BASE) >> 12) * pstc->i32PeakCnt) >> 15);
if (Q15(i32T1 + i32T2) > pstc->i32Q15_MaxDutyCnt) {//如果T1+T2超过了最大周期计数器值,则需要转换得到相电压Va/Vb
int32_t i32Q15_K = (pstc->i32Q15_MaxDutyCnt) / (i32T1 + i32T2);
i32T1 = ((i32Q15_K * i32T1) >> 15);
i32T2 = ((i32Q15_K * i32T2) >> 15);
pstc->i32Q12_VaReal = ((i32Q15_K * i32Q12_Va) >> 15);
pstc->i32Q12_VbReal = ((i32Q15_K * i32Q12_Vb) >> 15);
pstc->u8OvFlag = 1; //溢出标识
}
else {
pstc->i32Q12_VaReal = i32Q12_Va;
pstc->i32Q12_VbReal = i32Q12_Vb;
pstc->u8OvFlag = 0;
}
pstc->u16T1 = (uint16_t)(i32T1); //计算T1,T2,T0的值
pstc->u16T2 = (uint16_t)(i32T2);
i32Temp = pstc->i32PeakCnt - (int32_t)pstc->u16T1 - (int32_t)pstc->u16T2;
pstc->u16T0 = (uint16_t)i32Temp;
2 Svpwm_7SegSymmPwm函数中
if (1U == u8Sector)
{
pstc->u16Uon = (u16T0 >> 1U);
pstc->u16Von = pstc->u16Uon + u16T1;
pstc->u16Won = pstc->u16Von + u16T2;
}
/** sector 2: [0, 1, 0] -> [1, 1, 0] **************************************/
else if (2U == u8Sector)
{
pstc->u16Von = (u16T0 >> 1);
pstc->u16Uon = pstc->u16Von + u16T1;
pstc->u16Won = pstc->u16Uon + u16T2;
}
/** sector 3: [0, 1, 0] ->[0, 1, 1] ***************************************/
else if (3U == u8Sector)
{
pstc->u16Von = (u16T0 >> 1);
pstc->u16Won = pstc->u16Von + u16T1;
pstc->u16Uon = pstc->u16Won + u16T2;
}
/** sector 4: [0, 0, 1] -> [0, 1, 1] **************************************/
else if (4U == u8Sector)
{
pstc->u16Won = (u16T0 >> 1);
pstc->u16Von = pstc->u16Won + u16T1;
pstc->u16Uon = pstc->u16Von + u16T2;
}
/** sector 5: [0, 0, 1] -> [1, 0, 1]***************************************/
else if (5U == u8Sector)
{
pstc->u16Won = (u16T0 >> 1);
pstc->u16Uon = pstc->u16Won + u16T1;
pstc->u16Von = pstc->u16Uon + u16T2;
}
/** sector 6: [1, 0, 0] -> [1, 0, 1] **************************************/
else if (6U == u8Sector)
{
pstc->u16Uon = (u16T0 >> 1);
pstc->u16Won = pstc->u16Uon + u16T1;
pstc->u16Von = pstc->u16Won + u16T2;
}
else
{
pstc->u16Uon = 0xffff;
pstc->u16Von = 0xffff;
pstc->u16Won = 0xffff;
}
pstc->u16Uoff = pstc->u16Uon;
pstc->u16Voff = pstc->u16Von;
pstc->u16Woff = pstc->u16Won; |