You always want the timer to reload the same on each interrupt. By placing it inside IF/THEN statements, it can change depending on the conditions.
It also needs to be reloaded and re-started as soon as possible. Putting lot's of statements in-between turning the timer off and then back on again put's a variable amount of time in there as well.
Try it this way...Code:@Timer1 = TMR1L Timer1 VAR WORD EXT Disable miint: IF PIR1.0 = 1 THEN T1CON.0 = 0 Timer1 = Timer1 + FRECUENCIA T1CON.0 = 1 IF ARRANCA_MOTOR = 1 THEN PORTC.5 = 0 'PULSO DE STEP PORTA.5 = 0 'SALIDA PARA SHAFT PORTA.5 = 1 'SALIDA PARA SHAFT PORTC.5 = 1 'PULSO DE STEP ELSE IF EMULACION = 1 THEN IF ACTIVA_PRESENCIA = 0 THEN TRIGGER = 0 ELSE TRIGGER = 1 ENDIF ENDIF ENDIF '***************************************************************************************************** PIR1.0 = 0 ENDIF '**************************** INTERRUPCION POR TIMER 0 **************************** salida1: Resume ' retorna al programa principal Enable --------------------------------------------------------------------------------




Bookmarks