Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#define MIN_HRPWM_PRD_PERCENT (20.0003f)
void changeHZ(double zTemp)
{
uint32_t compCount = 0UL;
double iTemp = 0.0f;
uint32_t aTemp = 100000UL;
uint32_t xTemp = 0UL;
double yTemp = 0.0f;
iTemp = aTemp / zTemp;
xTemp = floor(iTemp); //取整数部分
yTemp = iTemp - xTemp; //减,以取小数部分
compCount=yTemp*256;
EPwm1Regs.TBPRD =xTemp-1;
EPwm1Regs.TBPRDHR = compCount<<8;
EPwm3Regs.TBPRD =xTemp-1;
EPwm3Regs.TBPRDHR = compCount<<8;
}
void main(void)
1,配置PWM1+PWM3的HRPWM输出,PWM3对PWM1移相
2,从20.0003kHZ开始加,每次加0.0001KHZ(也就是0.1HZ)
3,断点调试,示波器抓取频率,会正常改变:
4,延时低于800000us,示波器抓取频率,不按0.1HZ跳变 :
请问这是何故?