One part of my program won't work where I am using the COUNT command to count input pulses on an input pin. I know it isn't actually seeing any pulses and counting them because I am writing the count variable to EEPROM and then reading the EEPROM address after running the program. It continuously shows the value that was written to the EEPROM address as 0 (zero). I double checked to make sure that TRISA = $02 in my Register Settings so that RA1 is set to bit 1 and RA3 is set to bit 0.
Can anyone tell me what is wrong with this code that keeps COUNT from counting input pulses?
Thanks!
Code:
' Start measuring output of flow meter at RA1 input pin
i = 1 ' Preset pulse counter index to zero
WHILE i <= 10 'Assume the value CIN is a pulse count from the sensor
'Count the number of pulses from Hall Effect Magnetic Sensor in 10 sec
Count PORTA.1,10000,CIN
WRITE 5,CIN ' Write count into EEPROM location 5
'Slowly blink LED during water flow
HIGH PORTC.0 ' If we get here, Blink the LED slowly
PAUSE 200
LOW PORTC.0
Sleep 2 ' Wait 2 seconds
i = i + CIN ' Increment pulse count for last 10 sec
WEND 'When i = 10, required gallons have flowed by the meter
Bookmarks