Bruce, I moved the TMR0 = 0 clear statement after the WRITE statement. However, that is not the problem. I can see while running the code that the TMR0 value is never exceeding the value of K so it never enters the ELSE block and therefore never gets to the WRITE statement which leaves the EEPROM address at inital value of FF continuously.
All this is telling me that my approach to simulating the input pulses by momentarily grounding the RA2 port with my switch closure is not triggering the TMR0 count, but not quite sure what to do about that...I don't yet have access to the meter so I can use real pulse inputs from the sensor.
I understand what you are saying about the threshold value for Vih. However, my 16F690 is running off 5.0 volts, so I would have expected the voltage at RA2 to be near 5.0 volts when the switch is open (not grounded). Yet what I see is 1.8 volts, which is obviously not enough for Vih. This doesn't make sense to me, but explains why the TMR0 value is not incrementing. Any ideas why the RA2 port voltage would be at 1.8 vdc rather than 5.0 vdc when it is unloaded?
I also didn't quite understnd your comments about RA5. My code is a close modification of the Non-interrupt version code you posted above and doesn't even mention RA5 (see current code posting below). Are you saying I have to use RA5 somehow in generating the "clock" input to RA2??
Code:@ __config _INTRC_OSC_NOCLKOUT & _WDT_OFF & _MCLRE_OFF & _CP_OFF K CON 15 ' Calibration factor for flow meter = # pulses per gal ' Setup Timer0 as an 8-bit counter with the clock input on RA2. ' 1:1 TMR0 prescaler ' TMR0 counts on high-to-low transitions OPTION_REG = %00111000 ' A/D & Comparators disabled ANSEL=0 ' all digital ANSELH=0 ' analog module disabled CM1CON0=0 CM2CON0=0 ' Port setup PORTC = 0 ' LEDs off, PULSOUT RC3 provides a high-going pulse PORTA = 0 TRISC = %11110000 ' lower 4 pins outputs TRISA = %11111111 ' RA2 = 2TMR0 clock input for simulated meter pulse inputs TMR0 = 0 ' clear TMR0 count Main: IF TMR0 < K THEN ' Keep the valve open...do nothing..let water flow HIGH PORTC.0 ' Light LED continuously while water is flowing ELSE WRITE 7, TMR0 ' write before TMR0 cleared TMR0 = 0 ' clear TMR0 count Low PORTC.0 ' Blink LED on each clear after TMR0 >= K PAUSE 500 HIGH PORTC.0 PAUSE 500 LOW PORTC.0 PULSOUT PORTC.3,1000 ' Generate required 10 msec pulse to RC3 ENDIF GOTO Main END




Bookmarks