I'm not saying this is related to your problem but here:
This will "hold" until TMR1H is 128 and then countinue.Code:hold1: tempbyt=TMR1H if tempbyt<>128 then hold1
But for how long is TMR1H 128? Are you sure it's not (still) 128 the next time you check?
I would rewrite this.
* For pacing the loop, poll the TMR1 interrupt flag.
* Create a short subroutine for each "task". MeasureA, MeasureB, MeasureC, WriteEEPROM and so on.
* Have a LoopCount variable that counts from 0 to whatever.
* Use a Select Case block to execute whatever tasks are needed at each increment of the loop.
Crude example:Code:TMR1IF VAR PIR1.0 LoopCount VAR BYTE TMR1IF = 0 T1CON = %00110001 ' Prescaler = 1:8, Timer ON Main: IF TMR1IF=0 THEN Main ' Wait for TMR1 roll over TMR1IF=0 ' Reset interrupt flag. Select Case LoopCount Case 0 GOSUB MeasureA GOSUB MeasureB Case 1 GOSUB MeasureA GOSUB MeasureC Case 2 GOSUB MeasureA GOSUB MeasureB GOSUB MeasureC Case 3 GOSUB MeasureB GOSUB MeasureC GOSUB WriteEEPROM END SELECT LoopCount = LoopCount + 1 IF LoopCount = 4 THEN LoopCount = 0 Goto Main MeasureA: ' Do stuff RETURN MeasureB: ' Do Stuff RETURN MeasureC: ' Do Stuff RETURN WriteEEPROM: ' Do Stuff RETURN




Bookmarks