Clock does not exist! Use timer. #5
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. 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