Hi to all
I have some trouble with a code but I don't understand what is wrong : the code or a trouble from PBP3 compilation

1. First time if I turn ON the PIC and then RC with "varb <140 or varb > 160", the code go directly to BEEP
2. if I turn ON first time RC with "varb <140 or varb > 160" and then turn ON the PIC, the code wait in the INIT loop until "140 < varb < 160" and then go to BEEP

Can somebody help me with this trouble ?

1000 x thx in advance !



The code:
#CONFIG
__CONFIG _CONFIG1, _FCMEN_OFF & _FOSC_INTOSC & _WDTE_OFF & _MCLRE_OFF & _CP_ON & _IESO_OFF & _BOREN_OFF & _PWRTE_OFF
__CONFIG _CONFIG2, _PLLEN_OFF & _STVREN_OFF & _LVP_OFF
#ENDCONFIG

Define OSC 4
OSCCON = %01101010 'sets the internal oscillator to 4Mhz

ADCON0 = %00000000
ADCON1 = %00000000
FVRCON = %11000010 'turn fixed voltage reference on & set it to 2.048V
CM1CON0 = 0 ' COMPARATORS OFF
CM1CON1 = 0
CM2CON0 = 0
CM2CON1 = 0
CPSCON0 = 0 'CAPACTIVE SENSE MODULE OFF
RCSTA.7 = 0 'SERIAL PORT OFF

TRISA = %00000000
TRISC = %00000100
ANSELA = %00000000
ANSELC = %00000000

OPTION_REG.7 = 0
WPUA = %00000000
porta = 0
portc = 0

varb var byte

init:
pulsin portc.2 , 1, varb
pause 20
if varb < 140 or varb > 160 then init
if varb > 140 and varb < 160 then goto beep
goto init

beep:
...code....
goto beep
end