Previous

Next

Bottom

Contents

Glossary

Index

 

Persistor CF1 User's Manual

Periodic Interrupt Timer Functions

July 1998

Revision 1.01

 Persistor Instruments Inc.
© 1998 All rights reserved.

Quick Reference Table

PITAddChore

PITSet100usPeriod

PITInit

PITSet51msPeriod

PITRemoveChore

Background

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.

PITAddChore -- Add a periodic interrupt chore

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
intReqLevel is the interrupt request level that you wish your shore to be run at. It will never be higher than the level at which the PIT was initialized.

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

PITInit -- Initialize the periodic interrupt timer

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

PITRemoveChore -- Remove a periodic interrupt chore (NULL vfptr for all)

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

PITSet100usPeriod -- Set periodic interrupt timer period in 100us ticks

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

PITSet51msPeriod -- Set periodic interrupt timer period in 51ms ticks

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

 

 

Previous

Next

Top

Contents

Glossary

Index

Tel: 508-759-6434

Fax: 508-759-6436

Copyright (C) 1998 Persistor Instruments Inc. - All Rights Reserved