Code: Select all
while (1) {
switch (sys_state) {
case SYS_NOR_INFUSE: {
if (current_frequence < 7)
current_frequence = 7;
if (current_frequence > 5000)
current_frequence = 5000;
if (target_frequence <= current_frequence)
current_frequence = target_frequence;
else
current_frequence = current_frequence + 1;
/*the watch got triger may cause losing of step during the changing of frequence*/
//the frequence shoul changed smoothly or it may cause losing step
current_frequence = st() % 4900 + 8;
accu_pluse = accu_pluse +current_frequence;
if (ledc_get_freq(LEDC_HIGH_SPEED_MODE, MOTOR_TIMER)!= target_frequence)
{
ledc_set_freq(LEDC_HIGH_SPEED_MODE, MOTOR_TIMER,
current_frequence);
}
break;
}
}
pre_tick=st();/*updata pre_tick after the loop*/
vTaskDelay(5);/*to avoid the frequence changing too fast*/
}