Change CPU frequency without PM API
Change CPU frequency without PM API
Hello. I would like to change CPU frequency but without power manager API because I am having problems with timer accuracy when PM is enabled.
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Change CPU frequency without PM API
Changing CPU frequency without involving the PM API will only lead to more timer inaccuracies, as a lot of peripherals are dependent on the APB clock (which is partially connected to the CPU frequency); changing that without telling those drivers that something changed will mess things up, and the PM API is supposed to do that.
As an alternative, can you say what your issue is with timing inaccuracies? Perhaps there is a way to fix it or work around it.
As an alternative, can you say what your issue is with timing inaccuracies? Perhaps there is a way to fix it or work around it.
Re: Change CPU frequency without PM API
We are using the PM api function esp_pm_configure() with 10Mhz and 80Mhz clock speed and the 40Mhz oscillator and we are satisfied with the power consumption when running on 10MHz.
However when we enable the PM our timer is running 1.5 second fast over a minute so that timing accuracy is not acceptable. We would be happy if we could be within a second or two accuracy after a day so our timing goals are not unreasonable and we can easily attain this accuracy without the PM. What is causing the PM to throw off our timer accuracy and how can we fix this?
When running in 80MHz without PM, the timer accuracy is ok. But we need to switch to 10MHz to save power. And when we enable the PM, it happens what I mentioned. We are using the high resolution timer.
Thanks
However when we enable the PM our timer is running 1.5 second fast over a minute so that timing accuracy is not acceptable. We would be happy if we could be within a second or two accuracy after a day so our timing goals are not unreasonable and we can easily attain this accuracy without the PM. What is causing the PM to throw off our timer accuracy and how can we fix this?
When running in 80MHz without PM, the timer accuracy is ok. But we need to switch to 10MHz to save power. And when we enable the PM, it happens what I mentioned. We are using the high resolution timer.
Thanks
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Change CPU frequency without PM API
Gotcha. What timer specifically are you using, and how do you configure it?
Re: Change CPU frequency without PM API
Code: Select all
esp_timer_handle_t timer1;
void init_timer(int timer_period_us)
{
int64_t t_end;
esp_timer_create_args_t args = {
.callback = &timer_func,
.arg = &t_end,
.name = "timer1"
};
//----
esp_timer_create(&args, &timer1);
esp_timer_start_periodic(timer1, timer_period_us);
//esp_timer_delete(timer1);
}
// 1 sec high resolution timer
init_timer(1000000);
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Change CPU frequency without PM API
I think this is a documented issue with those timers. If your application is OK with some jitter, you could try setting skip_unhandled_events in the config struct, that way your time should stay stable long-term.
Re: Change CPU frequency without PM API
Alright, thanks for your reply.
But what options do we have for a timer with no jitter and low power?
But what options do we have for a timer with no jitter and low power?
-
- Posts: 9739
- Joined: Thu Nov 26, 2015 4:08 am
Re: Change CPU frequency without PM API
That is complicated, I don't think there is a wakeup source for a timer in the way you need it... an option might be to disable (automatic) light sleep altogether, but I don't know what that does for your power use.
Who is online
Users browsing this forum: bfredo123 and 68 guests