One of the various method to do it
Code:
@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _PWRTE_ON & _MCLRE_ON & _LVP_OFF & _BODEN_ON
TRISB=%00000011 ' Set RB0,RB1 to input, others to output
OPTION_REG.7=0 ' Enable internal pull-up on PORTB
LED VAR PORTB.7 ' connected between RB7 and GND via resistor
ClkIn var PORTB.0 ' connected between RB0 and GND
ClrEEP var PORTB.1 ' connected between RB1 and GND
Apulse VAR BYTE ' store the amount of pulse
Data @0,0 ' set count @ 0 at programming time
led=0 ' LED=OFF
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
' To Reset the value in the EEPROM, press on ClrEEP button while
' applying power. When the command is accepted, the LED will
' stay ON for 1 second
' //////////////////////////////|\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
'
if clreep=0 then ' is ClrEEP pushbutton is pressed
write 0,0 ' Reset the pulse count in EEPROM
led=1 ' LED = ON
pause 1000 ' wait 1 sec
led=0 ' LED=OFF
endif '
Read 0, Apulse ' Read count from internal eeprom
repeat
if clkin=0 then
while clkin=0 : wend
pause 50
apulse=apulse+1
WRITE 0,apulse ' save count in the internal EEPROM
endif
until apulse=10
led=1
Here:
goto here
Bookmarks