EPwm1Regs.TBPRD = EPWM1_CARRIER_WAVE_TBPRD;
时间: 2023-09-16 20:10:44 浏览: 180
This line of code sets the period of the time-base counter for ePWM1 module to the value of EPWM1_CARRIER_WAVE_TBPRD. The time-base counter determines the frequency of the PWM signal generated by the ePWM module. The value of EPWM1_CARRIER_WAVE_TBPRD is typically calculated based on the desired carrier frequency and the clock frequency of the system.
相关问题
解释一下EPwm1Regs.TBPRD>>1这段程序
EPwm1Regs.TBPRD 是指 EPWM1 模块的 Time-Base Period 寄存器,它决定了 PWM 的周期。而 ">>1" 是右移操作符,表示将 TBPRD 的值向右移动一位,相当于将其除以 2。这是因为在一些情况下,希望将 PWM 频率提高,而将 TBPRD 除以 2 可以使 PWM 周期减半,从而提高 PWM 频率。
switch(paramet[SELKHZ]) { case 1: { KHZCOEF = 1; FSW = 36000; EPwm7Regs.TBPRD = 1388; EPwm7Regs.CMPA.bit.CMPA = 695; EpwmTbpr = 1388; SINEND=720; break; } 695怎么算出来的
根据代码中的注释,可以看出这是用于设置EPwm7Regs.CMPA寄存器的值。根据参数设置的不同,EPwm7Regs.CMPA的值也不同。在这段代码中,EPwm7Regs.CMPA的值是通过将EPwm7Regs.TBPRD的一半减去345得到的。由于在此之前设置了EPwm7Regs.TBPRD为1388,所以EPwm7Regs.CMPA的值为695。
具体计算过程如下:
EPwm7Regs.CMPA = EPwm7Regs.TBPRD / 2 - 345
EPwm7Regs.CMPA = 1388 / 2 - 345
EPwm7Regs.CMPA = 694.5 ≈ 695
阅读全文