<<Previous

Next>>

 CALL

CALL Label

Execute the assembly language subroutine named Label.

GOSUB is normally used to execute a PICBASIC PRO™ subroutine. The main difference between GOSUB and CALL is that with CALL, Label=s existence is not checked until assembly time. Using CALL, a Label in an assembly language section can be accessed that is otherwise inaccessible to PBP.

See the section on assembly language programming for more information on CALL.

	CALL pass	' Execute assembly language subroutine named _pass

  CLEAR

CLEAR

Set all RAM registers to zero.

CLEAR zeroes all the RAM registers in each bank. This will set all variables, including the internal system variables to zero. This is not automatically done when a PBP program starts as it is on a BASIC Stamp. In general, the variables should be set in the program to an appropriate initial state rather than using CLEAR.

	CLEAR		' Clear all variables to 0

 CLEARWDT

CLEARWDT

Clear (tickle) the Watchdog Timer.

The Watchdog Timer is used in conjunction with the SLEEP and NAP instructions to wake the PICmicro after a certain period of time. Assembler instructions (clrwdt) to keep the Watchdog Timer from timing out under normal circumstances and resetting the PICmicro are automatically inserted at appropriate places throughout the program.

CLEARWDT allows the placement of additional clrwdt instructions in the program.

	CLEARWDT		' Clear Watchdog Timer

A DEFINE can be used to remove all of the clrwdt instructions the compiler automatically adds:

DEFINE NO_CLRWDT 1	'Don’t insert CLRWDTs

  COUNT

COUNT Pin,Period,Var

Count the number of pulses that occur on Pin during the Period and stores the result in Var. Pin is automatically made an input. Pin may be a constant, 0-15, or a variable that contains a number 0-15 (e.g. B0) or a pin name (e.g. PORTA.0).

The resolution of Period is in milliseconds. It tracks the oscillator frequency based on the DEFINEd OSC.

COUNT checks the state of Pin in a tight loop and counts the low to high transitions. With a 4MHz oscillator it checks the pin state every 20us. With a 20MHz oscillator it checks the pin state every 4us. From this, it can be determined that the highest frequency of pulses that can be counted is 25KHz with a 4MHz oscillator and 125KHz with a 20MHz oscillator if the frequency has a 50% duty cycle (the high time is the same as the low time).

	' Count # of pulses on Pin1 in 100 milliseconds
	COUNT PORTB.1, 100, W1

	' Determine frequency on a pin
	COUNT PORTA.2, 1000, W1		' Count for 1 second
	Serout PORTB.0, N2400, [W1]
<<Previous

Next>>