oTimer Object

Main Index
Object List
Back to top of page Description:
 A Hardware Object that controls the PIC's Timer1 Hardware Module. 

The PIC's Timer1 Hardware Module provides a 16-bit high speed counter with optional Crystal controlled frequency and input scaling.

The following table lists the size and availability of the oTimer Object.
 ObjectSizeDescriptionA1A2B1B2C1
oTimer1 ByteCounts the number of high-speed cycles on an input.xxxxx

Back to top of page Operation:
 The oTimer Object directly encapsulates the PIC's Timer1 Hardware Module.  (Timer1)  Timer1 counts each cycle of a clock source by incrementing a 16 bit value each time the clock source cycles.  When the 16-Bit value reaches a count of 65535, the next clock source cycle will roll the value back to 0.

The Count property directly reads and writes the Timer1 Module's 16-Bit value which consists of the TMR1L and TMR1H registers.

The ExtClock property specifies if the Timer1 Module is to count the cycles of an internal 5Mhz clock or the cycles present on a external clock supplied on I/O line 16. This property directly reads and writes the Timer1 Module TMR1CS bit.

The ExtXtal property specifies if I/O Line 16 is used in conjunction with I/O Line 17 for a crystal to be connected. This property directly reads and writes the Timer1 Module T1OSCEN bit.

The PreScale property specifies if and how the Timer1 Module divides the clock source cycles before they are counted. This property directly reads and writes the Timer1 Module T1CKPS bits.

The Operate property specifies if the Timer1 Module increments each time the clock source cycles. This property directly reads and writes the Timer1 Module TMR1ON bit.

Note that all instances of the oTimer object will use the PIC's Timer1 Hardware Module.  Therefore, all instances of the oTimer object will have the same 16-Bit count.  This includes instances of objects that use the oTimer object.

Back to top of page Properties:
 

The following table lists the properties of the oTimer Object:

Property

Description

Count
The current 16-Bit cycle count value.
Object Class: oWord Value Range: 0 - 65535
Data Type: Numeric Default Value: 0
ExtClock
A value that selects if the Timer1 Hardware uses I/O Lines or an internal clock for its clock source.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
ExtClockConstantDescription
0cvOff5Mhz internal clock is used as the input frequency to the Timer1 Module.
1cvOnI/O Lines 16 & 17 are used for the source of the input frequency to the Timer1 Module.
ExtXtal
A value that selects if the external crystal driver is enabled on the I/O Lines.
Object Class: oSelect0to1 Value Range: 0 - 1
Data Type: Numeric Default Value: 0
ExtXtalConstantDescription
0cvOffThe external crystal drive circuitry is disabled. The Timer1 Module uses only I/O line 16.
1cvOnThe external crystal drive circuitry is enabled. The Timer1 Module uses both I/O Lines 16 & 17.
PreScale
A value that selects which divisor is used to divide the clock input of the Timer1 Hardware.
Object Class: oSelect0to3 Value Range: 0 - 3
Data Type: Numeric Default Value: 0
PreScaleDescription
01:1 - The input clock is not changed.
11:2 - The input clock is divided by 2.
21:4 - The input clock is divided by 4.
31:8 - The input clock is divided by 8.
Operate
A value that selects whether or not the Timer1 Hardware is enabled and counts the cycles of the clock source.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe Timer1 Hardware is not enabled.
1cvOnThe Timer1 Hardware is enabled.
IOLineC
I/O Line 16 used as an external clock source.
Object Class: oIOLine Value Range: 16
Data Type: Numeric (Read-Only) Default Value: 16
IOLineX
I/O Line 17 used to drive the external crystal.
Object Class: oIOLine Value Range: 17
Data Type: Numeric (Read-Only) Default Value: 17
Address
Returns a pointer to the address of the oCounter Object instance.
Object Class: oAddress Value Range: 0 - 127
Data Type:Pointer (Read Only) Default Value: Address of Object

Back to top of pageHardware Diagram:
 The PIC's Timer1 Module.

Back to top of page Example:

 In the following example, the oTimer Object's Count property is outputted on the oDio16's 16 I/O lines.
' Copy the oTimer's
' Value to an oDio16.

Dim T As New oTimer
Dim D As New oDIO16 

Sub Main()
  D.Direction = cvOutput
  T.Operate = 1
  T.PreScale = 3
  T.Operate = cvTrue
  Do
    D.State = T.Count
  Loop 
End Sub

Back to top of page Related Items:

 The following table lists objects that use the oTimer Object.
 ObjectDescriptionA1A2B1B2C1
oCounter2HCounts the number of high-speed cycles on an input using hardware specific I/O lines.xxx
oFreqHOutputs a high frequency square wave using hardware specific I/O lines.xx
oCCPControls one of the PIC's Capture Hardware Module.x
 The following table lists other objects with related functions.
 ObjectDescriptionA1A2B1B2C1
oClockProvides a programmable logic clockxxx
oCountDown(O)Counts down to 0.xxx
oCounterProvides counting functions.xxxxx
oOperatingSystemProvides a 1 Hertz and 60 Hertz clock.xxxxx
Back to top of page Version History and Bug List:
 Firmware Ver A1: Introduced.

Bugs: No known bugs.


 

ooPIC Compiler Ver 6.0 (c) Copyright 1997 - 2007 Savage Innovations, LLC.