Skip to content

Introduction

Ivan Cenov edited this page Feb 14, 2019 · 2 revisions

Introduction

This module defines various types of timers that may be used for measuring single time intervals or for triggering events at even time intervals. Some of the timers are more complex - they can count forward and backward and this way to participate in simulating physical processes - par example heating and cooling of an electronic unit. Most complex timers are capable to produce bursts of impulses.

All of the timers depend on the system real-time clock (RTC). The RTC usually uses one of the microcontroller's embedded timers which is configured to make interrupts at even intervals (2.5ms to 10ms are reasonable values). The interval RTC ticks (the interrupts of embedded timer happen) is named RTC_TICK.

The timers can be defined with various lengths of the counters. They can measure short time intervals and in such cases, they can be defined with uint8_t counters. For longer intervals, uint16_t or even uint32_t can be used. Each timer has DEFINE and EXTERN macros that declare and define timer's variables. These macros accept as an argument an integral unsigned type (uint8_t, uint16_t, uint24_t (in XC8), uint32_t etc) that is the type of the counters. All other macros that manipulate the timers do not use a time argument. Thus, it is very easy to change the type of timer to a shorter or longer one if needed.

The module is created and tested for use in embedded projects with Microchip's PIC12 and PIC16 families. Without or with little adaptations, it may be extended to the other PIC families or other microcontrollers, or why not to be used in desktop applications.

Clone this wiki locally