打印

PWM产生的原函数求解释啊?主要是他怎么算的

[复制链接]
980|2
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
554782398|  楼主 | 2014-4-12 20:55 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
void F281X_EV1_PWM_Update(PWMGEN *p)
{      
                int16 MPeriod;
        int32 Tmp;

// Compute the timer period (Q0) from the period modulation input (Q15)
        Tmp = (int32)p->PeriodMax*(int32)p->MfuncPeriod;           // Q15 = Q0*Q15
        MPeriod = (int16)(Tmp>>16) + (int16)(p->PeriodMax>>1);     // Q0 = (Q15->Q0)/2 + (Q0/2)
        EvaRegs.T1PR = MPeriod;  

// Compute the compare 1 (Q0) from the PWM 1&2 duty cycle ratio (Q15)
        Tmp = (int32)MPeriod*(int32)p->MfuncC1;                    // Q15 = Q0*Q15
        EvaRegs.CMPR1 = (int16)(Tmp>>16) + (int16)(MPeriod>>1);    // Q0 = (Q15->Q0)/2 + (Q0/2)

// Compute the compare 2 (Q0) from the PWM 3&4 duty cycle ratio (Q15)
        Tmp = (int32)MPeriod*(int32)p->MfuncC2;                   // Q15 = Q0*Q15
        EvaRegs.CMPR2 = (int16)(Tmp>>16) + (int16)(MPeriod>>1);   // Q0 = (Q15->Q0)/2 + (Q0/2)

// Compute the compare 3 (Q0) from the PWM 5&6 duty cycle ratio (Q15)
        Tmp = (int32)MPeriod*(int32)p->MfuncC3;                   // Q15 = Q0*Q15
        EvaRegs.CMPR3 = (int16)(Tmp>>16) + (int16)(MPeriod>>1);   // Q0 = (Q15->Q0)/2 + (Q0/2)
        }

这个函数中MfuncC1,MfuncC3,MfuncC3,是 svgendq模块产生的Ta,Tb,Tc。然后由于算三个寄存器的值。我的疑问是他怎么算的啊.....我看书上说的应该是CMPR3=Tc/时钟周期啊.....可是他这里怎么搞得啊?

相关帖子

沙发
zhangmangui| | 2014-4-12 23:05 | 只看该作者
不知道怎么算的

使用特权

评论回复
板凳
554782398|  楼主 | 2014-4-13 20:26 | 只看该作者
哦~....有木有知道呢~

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

2

主题

3

帖子

0

粉丝