Clock does not exist! Use timer. #5

Closed
opened 6 years ago by Ruakij · 3 comments
Ruakij commented 6 years ago (Migrated from gitea.railduction.eu)

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)

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)
Ruakij commented 6 years ago (Migrated from gitea.railduction.eu)

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 0

Still todo:

  • Check effects of overflowing nextTick and overflowing timer
Example timer code:<br><br> <code>// Using timer1 (16-bit)</code><br> <code>TCCR1B |= (1 << CS10); // This sets the prescaler</code><br> <code>TCNT1 = 0; // initialize counter</code> <br> <br> Outside can then <code>TCNT1</code> be used as variable.<br> The timer will count up to <code>2^16 = 65536-1</code> and then overflows to 0<br><br> Still todo:<br> - Check effects of overflowing nextTick and overflowing timer
Ruakij commented 6 years ago (Migrated from gitea.railduction.eu)

16-bit timer is now implemented



Still Todo:

  • Check timer variable if its signed or unsigned
16-bit timer is now implemented<br> <br> Still Todo: - Check timer variable if its signed or unsigned
Ruakij commented 6 years ago (Migrated from gitea.railduction.eu)

Timer fully implemented

Timer fully implemented
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: Ruakij/Geigercounter#5
Loading…
There is no content yet.