Hi All,
Thanks for all ideas and suggestions 
I tried them all except the one toggeling the port since I need to read that flag for different actions in the full program.
Unfortunately, none of them work in a "one second ON - a second OFF" rhythm.
Anyway, the way I found to make it work is to change the Flag BIT var to a BYTE one and sum up the number of PIR1.0 changes into the Flag var to trigger a port TOGGLE.
Still, I don't understand why this code doesn't work (it actually works, but in a 0.5 sec rhythm)
Code:
' PIC 16F690
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
OPTION_REG = %10000000
OSCCON = %01100000 ' Internal oscillator 4MHz
ANSEL = %00000000 ' analog inputs Channels 0 to 7
ANSELH = %00000000 ' analog inputs Channels 8 to 11
T1CON = %00110001 ' <5:4> prescaler 1:8, <1> Timer1 enabled
DEFINE OSC 4
Flag VAR BIT
CAL_H CON 11
CAL_L CON 219
Flag = 0
MAIN:
IF PIR1.0 THEN
PIR1.0 = 0
Flag = Flag + 1
TMR1H = CAL_H : TMR1L = CAL_L
ENDIF
IF Flag THEN
Flag = 0
TOGGLE PORTC.0
ENDIF
GOTO MAIN
END
...while this one will light the LED for one second and switch it OFF for another second (= what I finally want):
Code:
' PIC 16F690
@ __config _FCMEN_OFF &_IESO_OFF &_CPD_OFF &_WDT_OFF &_INTRC_OSC_NOCLKOUT &_BOR_OFF &_CP_OFF &_PWRTE_OFF &_MCLRE_OFF
OPTION_REG = %10000000
OSCCON = %01100000 ' Internal oscillator 4MHz
ANSEL = %00000000 ' analog inputs Channels 0 to 7
ANSELH = %00000000 ' analog inputs Channels 8 to 11
T1CON = %00110001 ' <5:4> prescaler 1:8, <1> Timer1 enabled
DEFINE OSC 4
Flag VAR BYTE
CAL_H CON 11
CAL_L CON 219
Flag = 0
MAIN:
IF PIR1.0 THEN
PIR1.0 = 0
Flag = Flag + 1
TMR1H = CAL_H : TMR1L = CAL_L
ENDIF
IF Flag > 1 THEN
Flag = 0
TOGGLE PORTC.0
ENDIF
GOTO MAIN
END
Bookmarks