Clock does not exist! Use timer.
#5
Closed
opened 6 years ago by Ruakij
·
3 comments
Loading…
Reference in New Issue
There is no content yet.
Delete Branch '%!s(<nil>)'
Deleting a branch is permanent. It CANNOT be undone. Continue?
Because we cannot use clock() and clock_t, because it does not exist in the library timer.h, we have to use an internal timer.
The timer should be precise enough to measure differences reliably up to 20kHz
(Example stepping: Half-Period-Time / 5)
Example timer code:
// Using timer1 (16-bit)
TCCR1B |= (1 << CS10); // This sets the prescaler
TCNT1 = 0; // initialize counter
Outside can then
TCNT1
be used as variable.The timer will count up to
2^16 = 65536-1
and then overflows to 0Still todo:
16-bit timer is now implemented
Still Todo:
Timer fully implemented