average tick interrupt interval
This commit is contained in:
parent
d1f2a16835
commit
06d189e08c
2 changed files with 11 additions and 1 deletions
|
@ -45,6 +45,9 @@ kw11_l::~kw11_l()
|
||||||
void kw11_l::show_state(console *const cnsl) const
|
void kw11_l::show_state(console *const cnsl) const
|
||||||
{
|
{
|
||||||
cnsl->put_string_lf(format("CSR: %06o", lf_csr));
|
cnsl->put_string_lf(format("CSR: %06o", lf_csr));
|
||||||
|
|
||||||
|
if (n_t_diff)
|
||||||
|
cnsl->put_string_lf(format("Average tick interrupt interval: %.3f ms", double(t_diff_sum) / n_t_diff));
|
||||||
}
|
}
|
||||||
|
|
||||||
void kw11_l::begin(console *const cnsl)
|
void kw11_l::begin(console *const cnsl)
|
||||||
|
@ -96,11 +99,15 @@ void kw11_l::operator()()
|
||||||
// - 50 Hz depending on instrution count
|
// - 50 Hz depending on instrution count
|
||||||
// - nothing executed in interval
|
// - nothing executed in interval
|
||||||
// - 10 Hz minimum
|
// - 10 Hz minimum
|
||||||
if (took_ms >= 1000 / 50 || current_cycle_count - interval_prev_cycle_count == 0 || now - prev_tick >= 100) {
|
auto t_diff = now - prev_tick;
|
||||||
|
if (took_ms >= 1000 / 50 || current_cycle_count - interval_prev_cycle_count == 0 || t_diff >= 100) {
|
||||||
do_interrupt();
|
do_interrupt();
|
||||||
|
|
||||||
prev_cycle_count = current_cycle_count;
|
prev_cycle_count = current_cycle_count;
|
||||||
|
|
||||||
|
t_diff_sum += t_diff;
|
||||||
|
n_t_diff++;
|
||||||
|
|
||||||
prev_tick = now;
|
prev_tick = now;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
3
kw11-l.h
3
kw11-l.h
|
@ -24,6 +24,9 @@ private:
|
||||||
#endif
|
#endif
|
||||||
uint16_t lf_csr { 0 };
|
uint16_t lf_csr { 0 };
|
||||||
|
|
||||||
|
int64_t t_diff_sum { 0 };
|
||||||
|
uint64_t n_t_diff { 0 };
|
||||||
|
|
||||||
std::atomic_bool stop_flag { false };
|
std::atomic_bool stop_flag { false };
|
||||||
|
|
||||||
uint8_t get_lf_crs();
|
uint8_t get_lf_crs();
|
||||||
|
|
Loading…
Add table
Reference in a new issue