oCCP Object

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

The PIC's Capture Hardware Module provides a 16-bit high speed counter capture.

The following table lists the size and availability of the oCCP Object.
 ObjectSizeDescriptionA1A2B1B2C1
oCCP4 ByteControls one of the PIC's Capture Hardware Module.x

Back to top of page Operation:
 The oCCP Object directly encapsulates the PIC's CCP1 Hardware Module.  (CCP1)  The CCP1 Hardware Module captures the 16-bit value of the Timer1 Hardware Module when an event occurs on I/O Line 17 (RC2/CCP1). 

When the Operate property is set to 1, the oCCP object first configures the Timer1 Hardware Module and then sets the CCPxM3 bit which turns the CCP Module on at which time to will begin to wait for the event to occur.

The Mode property selects the event that causes the capture which can be one of the following:

  • Every falling edge

  • Every rising edge

  • Every 4th rising edge

  • Every 16th rising edge

When the event occurs, the 16-bit value of the Timer1 Hardware Module is captured and placed into the Value property.  If another capture occurs before the Value property is read, the old captured value is overwritten by the new value.  When to operate property transitions from 0 to 1, the Mode property is copies to the CCP Module's CCPxM1 and CCPxM0 bits.

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

The Timer property is an instance of the oTimer object which the oCCP object uses.  When the operate property transitions from 0 to 1, the oCCP object configures the Timer's properties so that it will use an internal clock with a 1:1 prescale.   Attributes of the Timer object's operation can be adjusted by directly manipulating it, but note that doing so may change the way the the oCCP object works to something different than described in this document.   (see oTimer Object for more detail).

Back to top of page Properties:
 

The following table lists the properties of the oCCP Object:

Property

Description

Value
The last captured 16-Bit count value.
Object Class: oWord Value Range: 0 - 65535
Data Type: Numeric Default Value: 0
Mode
A value that selects the event that causes the capture.
Object Class: oSelect0to3 Value Range: 0 - 3
Data Type: Numeric Default Value: 0
Any changes to this property will be ignored until the operate property transitions from 0 to 1.
PreScaleDescription
0Every falling edge
1Every rising edge
2Every 4th rising edge
3Every 16th rising edge
Operate
A value that selects whether or not the CCP Hardware is enabled.
Object Class: oOperate Value Range: 0 - 1
Data Type: Numeric Default Value: 0
OperateConstantDescription
0cvOffThe CCP Hardware is not enabled.
1cvOnThe CCP Hardware is enabled.
IOLine
I/O Line 17 used as the pulse input line.
Object Class: oIOLine Value Range: 17
Data Type: Numeric (Read-Only) Default Value: 17
Timer
The PIC Hardware object used to time the pulse signal.
Object Class: oTimer Value Range: 0 - 65535
Data Type: Numeric Default Value: 0
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 CCP and Timer1 Modules.

Back to top of page Example:

 In the following example, the oCCP Object's is used.
Visual Basic SyntaxC and Java Syntax
' This program measures the cycle
' time on I/O Line 17 and displays
' the result on I/O Group 1 and 3.

Dim C As New oCCP
Dim D As New oDIO16

Sub main()
  C.Mode = 1
  C.Operate = 1
  D.Direction = cvOutput
  Do
    D.State = C.Value 
  Loop
End Sub
// This program measures the cycle
// time on I/O Line 17 and displays
// the result on I/O Group 1 and 3. 

oCCP C = New oCCP;
oDIO16 D = New oDIO16;

Void main(Void){
  C.Mode = 1;
  C.Operate = 1;
  D.Direction = cvOutput;
  Do{
    D.State = C.Value;
  } While (1);
}
Basic Syntax 
' This program measures the cycle
' time on I/O Line 17 and displays
' the result on I/O Group 1 and 3.

C Var oCCP(1,cvOn)
D Var oDIO16(cvOutput)

Do
  D.State = C.Value 
Loop
 

Back to top of page Related Items:

 The following table lists objects that use the oCCP Object.
 ObjectDescriptionA1A2B1B2C1
oPulseTimeHMeasures the pulse time of a high-frequency input using a hardware specific I/O line.x
oCycleTimeHMeasures the cycle time of a high-frequency input using a hardware specific I/O line.x
 The following table lists other objects with related functions.
 ObjectDescriptionA1A2B1B2C1
oCycleTimeLMeasures the cycle time of an low-frequency input on any I/O line.xxx
Back to top of page Version History and Bug List:
 Firmware Ver C1: Introduced.

Bugs: No known bugs.


 

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