Try this. Changes are in Bold
Code:'---[INT - interrupt handler]------Signal found at RB0, take a reading SignalFound: T1CON.0 = 0 ; Stop timer1 i = i + 1 FValue = TMR1H * 256 + TMR1L + fvalue ; Add 10 readings to FValue if i >= 10 then ' COMPARISON CHANGED TO >= fvalue = fvalue / i ; get the average of one reading CHANGED HERE i = 0 ; Reset counter ReadFlag = 1 ; FValue is ready to read endif TMR1H = 21 ; reset timer1 to 60mS TMR1L = 167 T1CON.0 = 1 ; Start timer1 @ INT_RETURN




Bookmarks