Previous

Next

Bottom

Contents

Glossary

Index

 

Persistor CF1 User's Manual

Timing Functions

July 1998

Revision 1.01

 Persistor Instruments Inc.
© 1998 All rights reserved.

Quick Reference Table

DelayXXus

TMGPreChgRemoveChore

TMGGetSpeed

TMGSetSpeed

TMGInit

TMGSetSysClock

TMGPostChgAddChore

TMGSetupCLKOUTPin

TMGPostChgRemoveChore

TMGUpdateLoopDelays

TMGPreChgAddChore

Timing Functions

These functions allow for user control of the CF1's system clock and all of the issues surrounding system clock changes. These functions provide a mechanism for management of clock changes and also provide macros for short, accurate delays with greater resolution and accuracy than the delay functions offered by the real time clock module.

DelayXXus -- A group of macro functions that delay for specific amounts of time

This group of functions is a list of macros that allow for easy delays of fixed periods of time at a resolution greater than can be offered by the real time clock. Valid substitutions for XX in the function name are 1,2,5,10,20,50,100,200,500, and there is one other function Delay1ms. These functions will return after the specified amount of time. These functions should have a maximum error of 2 µs.

Prototype:

void TMGUpdateLoopDelays(void);

Definition:

#include <cf1bios.h>

Notes:

Clearly with a maximum error of 2µs the Delay1us() and Delay2us() functions are kind of irrelevant. They are included as placeholders to maintain the consistency of the group of macros. For shorter delays in your specific application, you may be able to take your knowledge of the running clock rate and use NOOP() to delay for a very short amount of time.( NOOP() is a macro that puts in a 68000 NOOP instruction. i.e. at 16 MHz a decent way to effect a 1 µs delay would be to call NOOP() 4 times.)

Timing:

within 2µs of the XX in DelayXXus.

TMGGetSpeed -- Return the system clock frequency in kHz

This function returns the current system clock speed in kilohertz.

Prototype:

ushort TMGGetSpeed(void);

Definition:

#include <cf1bios.h>

Returns:

Returns the current clock speed in kilohertz.

Notes:

Timing:

Timing-TBD

TMGInit -- Initialize the timing module

This function is called at power-up and reset by the normal BIOS startup and sets the default clock speed at 16 MHz. This function will never be called by a user application unless the application needs to patch the startup sequence of the Persistor.

Prototype:

void TMGInit(ushort kHz);

Definition:

#include <cf1bios.h>

Inputs:

kHz is the desired clock frequency in kilohertz.

Notes:

Timing:

Timing-TBD

TMGPostChgAddChore -- Add a timing post-change chore

This function allows you to perform one or more small tasks, immediately after a clock change, in order to handle any hardware that might be sensitive to a clock change. The maximum number of chores is defined in cf1bios.h as MAX_TMG_CHG_CHORES and then the BIOS installs two chores of its own so the actual number of chores you can add is (MAX_TMG_CHG_CHORES - 2) The priority you pass is an internal sorting order (0-7) to indicate the order in which the chores get executed. (priority 7 is executed first and 0 is last.)

Prototype:

bool TMGPostChgAddChore (vfptr chore, ushort priority);

Definition:

#include <cf1bios.h>

Inputs:

chore is a volatile function pointer to the chore you wish to install
priority is a parameter used as an internal sorting order for the tasks. (0-7)

Returns:

Returns a boolean that is TRUE if the chore was successfully added.

Notes:

These chores should be kept small. A good rule of thumb is to keep the total execution time of all chores combined under 100µs.

Timing:

Timing-TBD

TMGPostChgRemoveChore -- Remove a timing post-change chore

This function removes a post-clock change chore from the clock change chore list, previously installed by TMGPostChgAddChore.

Prototype:

bool TMGPostChgRemoveChore(vfptr chore)

Definition:

#include <cf1bios.h>

Inputs:

chore is a volatile function pointer to a chore that was perviously installed by the TMGPostChgAddChore function

Returns:

Returns a boolean that is TRUE if the chore was successfully removed.

Notes:

Timing:

Timing-TBD

TMGPreChgAddChore -- Add a timing pre-change chore

This function allows you to perform one or more small tasks, immediately before a clock change, in order to prepare any hardware that might be sensitive to a clock change. The maximum number of chores is defined in cf1bios.h as MAX_TMG_CHG_CHORES and then the BIOS installs two chores of its own so the actual number of chores you can add is (MAX_TMG_CHG_CHORES - 2) The priority you pass is an internal sorting order (0-7) to indicate the order in which the chores get executed. (priority 7 is executed first and 0 is last.)

Prototype:

bool TMGPreChgAddChore(vfptr chore, ushort priority);

Definition:

#include <cf1bios.h>

Inputs:

chore is a volatile function pointer to the chore you wish to install
priority is a parameter used as an internal sorting order for the tasks. (0-7)

Returns:

Returns a boolean that is TRUE if the chore was successfully added.

Notes:

These chores should be kept small. A good rule of thumb is to keep the total execution time of all chores combined under 100µs.

Timing:

Timing-TBD

TMGPreChgRemoveChore -- Remove a timing pre-change chore

This function removes a pre-clock change chore from the clock change chore list, previously installed by TMGPreChgAddChore.

Prototype:

bool TMGPreChgRemoveChore(vfptr chore)

Definition:

#include <cf1bios.h>

Inputs:

chore is a volatile function pointer to a chore that was perviously installed by the TMGPreChgAddChore function

Returns:

Returns a boolean that is TRUE if the chore was successfully removed.

Notes:

Timing:

Timing-TBD

TMGSetSpeed -- Set the system clock frequency in kHz

TMGSetSpeed changes the system clock to the frequency passed to it. The system is clocked from a voltage-controlled oscillator controlled by a phase-locked loop which is built into the 68338. There are restrictions on the frequencies that can be set(see notes section).

Prototype:

ushort TMGSetSpeed(ushort kHz);

Definition:

#include <cf1bios.h>

Inputs:

kHz is the desired clock frequency in kilohertz

Returns:

The actual clock frequency set.

Notes:

With two exceptions, all clock speeds must be multiples of 320 kHz for clock speeds between 0 and 20.48MHz and above that, all speeds must be multiples of 640 kHz. The two exceptions are 160 kHZ(the lowest operating frequency of the CF1), and 3.68 MHz which is a frequency that allows convenient access to many standard baud rates. If these restrictions are not met, the Persistor will adjust your frequency to the nearest valid one before making the change.

Timing:

Timing-TBD

TMGSetSysClock -- Set the system clock frequency with option lock wait disable

TMGSetSysClock changes the system clock to the frequency (in kilohertz) passed to it. There are restrictions on the frequencies that can be chosen(see notes section). The system is clocked from a voltage-controlled oscillator controlled by a phase-locked loop which is built into the 68338. TMGSetSysClock provides similar functionality to TMGSetSpeed, however if has another parameter that offers additional functionality. When a clock speed change occurs normally, execution will suspend for about 8 ms while the PLL driving the clock oscillator re-locks. TMGSetSysClock, unlike TMGSetSpeed, allows execution to continue while the PLL is re-locking. During this re-locking however, the clock frequency will be unpredictable and all timing routines are virtually useless.

Prototype:

short TMGSetSysClock(ushort kHz, bool dontWaitLock);

Definition:

#include <cf1bios.h>

Inputs:

kHz is the desired new clock frequency in kilohertz. (See notes for restrictions)
dontWaitLock is TRUE if you wish execution to return immediately before the PLL re-locks on the new frequency.

Returns:

The actual clock frequency set.

Notes:

With two exceptions, all clock speeds must be multiples of 320 kHz for clock speeds between 0 and 20.48MHz and above that, all speeds must be multiples of 640 kHz. The two exceptions are 160 kHZ(the lowest operating frequency of the CF1), and 3.68 MHz which is a frequency that allows convenient access to many standard baud rates. If these restrictions are not met, the Persistor will adjust your frequency to the nearest valid one before making the change.

Timing:

Timing-TBD

TMGSetupCLKOUTPin -- Determine the state of the 68338 CLKOUT pin

The 68338 microcontroller has a pin called CLKOUT which mirrors the system clock, for possible use by other devices. This function is off by default, but can be turned on using this function. Having this pin active increases the current drain of the 68338 by a small but noticeable amount. The two options are for running mode and low power mode. Normally both are passed as FALSE but if onRunning is TRUE and onLPSTOP is FALSE, then the pin will not be active when the machine is in LPSTOP mode. For a detailed discussion relating to the LPSTOP mode and other low power modes please refer to the power management section.

Prototype:

void TMGSetupCLKOUTPin(bool onRunning, bool onLPSTOP);

Definition:

#include <cf1bios.h>

Inputs:

onRunning is a boolean that indicates whether CLKOUT should be on while the machine is running
onLPSTOP is a boolean that indicates whether CLKOUT should be on while the machine is in LPSTOP mode.

Notes:

Timing:

Timing-TBD

TMGUpdateLoopDelays -- Recalibrate loop delays.

It is extremely unlikely that this function will ever e used by a user application, but if you were to disable the BIOS clock change chores, and then execute a clock change, the delay functions DelayXXus() would yield unpredictable results. This function can be called to recalibrate these delay functions is the extremely unlikely event that you need to remove the automatic recalibration chores done by the BIOS at the time of a clock change.

Prototype:

void TMGUpdateLoopDelays(void);

Definition:

#include <cf1bios.h>

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