PDA

View Full Version : help plz



CuE0079
- 25th June 2004, 16:46
im trying to make a program where u press a button and the pic measures how long u hold down the button in milliseconds. i use the PIC16F877A and my compiler is PicBasic. plz help me =)

MegaADY
- 26th June 2004, 15:02
You may use RCTIME instruction.

RCTIME Pin,State,Var

RCTIME measures the time a Pin stays in a particular State. 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 RCTIME is dependent upon the oscillator frequency. If a 4MHz oscillator is used, the time in state is returned in 10us increments. If a 20MHz oscillator is used, the time in state will have a 2us resolution. Defining an OSC value has no effect on RCTIME. The resolution always changes with the actual oscillator speed. If the pin never changes state, 0 is returned.

Example
RCTIME PORTB.3,0,W0 ' W0 returns the time (in us), for how long the pin PortB.3 was in 0 state.

If you need more assistance, do not hesitate to contact me.
Good luck !