Embedded Developer

Case File: The Clock That Rolls Over

A controller that runs for weeks and then misbehaves every fifty days is the classic result of a time comparison that was not written for the moment the millisecond counter wraps. Run periodic tasks from a list of counter readings, using an elapsed time computed with an unsigned subtraction, count how many times each task runs, how many times the counter wraps and the total elapsed time, and work out how many days pass until a wrap. Run it on readings that you cannot see. The readings are generated for you alone.

50 min

Case File: The Clock That Rolls Over

A controller that runs for weeks and then misbehaves every fifty days is the classic result of a time comparison that was not written for the moment the millisecond counter wraps. Run periodic tasks from a list of counter readings, using an elapsed time computed with an unsigned subtraction, count how many times each task runs, how many times the counter wraps and the total elapsed time, and work out how many days pass until a wrap. Run it on readings that you cannot see. The readings are generated for you alone.

In this lesson:

  • millis
  • timing
  • overflow
  • scheduler
  • python
  • case-file

๐Ÿ”’ This lesson is part of a paid plan

This lesson is part of the Pro plan. Upgrade to unlock the full lesson, the labs and the exam.

Upgrade Now

This lesson is part of a paid plan

Upgrade to Pro to unlock this course, its labs and its exam.

View Pricing Plans