|
|
|
|
|
|
|
||
|
||
|
|
||
July 1998 |
Revision 1.01 |
|
Persistor Instruments Inc. |
© 1998 All rights reserved. |
|
The Periodic Interrupt Timer offers a more precise method to execute timed chores in a more controlled environment than the real time clocks once-per-second timed task. You may specify intervals from 100µs all the way to 13 seconds and execute your chores at those times. The PIT is clocked directly from the main 40kHz system crystal and continues to run even when the system enters LPSTOP and shuts down the main PLL that generates the main system clock. This makes PIT interrupts an ideal way to regulary wake the system when it's sleeping in low power (though not from SUSPEND).
The PIT has an 8-bit modulus counter and an optional divide by 512 prescaler. With the prescaler off, the basic interval is 4/40kHz (exactly 100us) per count for a range of 100us to 25.5us. With the prescaler on, the basic interval is 4*512/40kHz (approximately 51.2ms) per count for a range of 51ms to 13s.
This function adds a chore to the list of chores to be executed at the interval specified with either: PITSet100usPeriod or PITSet51msPeriod. This chore is executed in an interrupt so the standard interrupt guidelines apply with regards to execution speed. The interrupt request level you pass to this function is the interrupt request level you wish the chore to be executed at. However, the chore will never execute at a higher priority than the PIT was initialized at.
|
Prototype: |
bool PITAddChore(vfptr chore, ushort intReqLevel); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
chore is a volatile function pointer to the chore
to be installed |
|
Returns: |
Returns TRUE if the chore was successfully added to the list. |
|
Notes: |
These chores should be kept fairly short. A good rule of thumb is to keep all of the chores to a combined maximum duration of 100µs. |
|
Timing: |
Timing-TBD |
This function is generally called automatically by the operating system before your program runs, though in special cases, you may override the OS and sequence the initialization process yourself (see Startup). This function lays all the groundwork for the Periodic Interrupt timer but does not start the timer or install any chores.
|
Prototype: |
void PITInit(ushort intReqLevel); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
intReqLevel is the interrupt request level (0-7) that the PIT will run at. (Default is 6) |
|
Notes: |
|
|
Timing: |
Timing-TBD |
This function removes a chore from the PIT chore list that was perviously added by the PITAddChore function. Pass NULL (zero) for the chore parameter to remove all PIT chores.
|
Prototype: |
bool PITRemoveChore(vfptr chore); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
chore is a pointer to a function that was installed with the PITAddChore function. |
|
Returns: |
Returns TRUE if the chore was successfully removed. |
|
Notes: |
|
|
Timing: |
Timing-TBD |
This function specifies the how often the PIT interrupts in units of 100 µs. Because the register that holds the period is only 8 bits, this function can only specify delays of 100µs to 25.5ms. When this function is called, it not only sets the period but actually starts the timer and the chores begin.
|
Prototype: |
void PITSet100usPeriod(uchar per100us); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
per100us is the number of 100µs intervals between PIT interrupts. |
|
Notes: |
|
|
Timing: |
Timing-TBD |
This function specifies the how often the PIT interrupts in units of 51 ms. This function is provided because PITSet100usPeriod can only provide delays of up to 25.5 ms. This function expands that range by allowing you to specify delays of 51ms to 13s. When this function is called, it not only sets the period but actually starts the timer and the chores begin.
|
Prototype: |
void PITSet51msPeriod(uchar per51ms); |
|
Definition: |
#include <cf1bios.h> |
|
Inputs: |
per51ms is the number of 51ms intervals between PIT interrupts. |
|
Notes: |
|
|
Timing: |
Timing-TBD |
|
|
|
|
|
|
Tel: 508-759-6434 |
|
Fax: 508-759-6436 |
|
|
||