Hi, I added the config rutine and the write statement. But It isn't working. I write a validtion rutine to chek if the WRITE was ok, but I get It's not.
In the 16f84a datasheet says that the error could be caused for a WDT reset or a MCLR reset.
I dissable the WDT, both on pbp and in the fuses, so the only one left is the MCLR reset.
How can I avoid that, considering that everything else is working fine?
I have a 4.7K resistor to MCLR and +5V.


define osc 4

Define NO_CLRWDT 1

TRISA = %00000000
TRISB = %00000111

intcon = 0


clear

num var byte
x var word
pulsos var byte
cuenta var byte
velocidad var word
circunferencia var byte
demora var byte

t1 var portb.4
t2 var portb.5
t3 var portb.6

timer con 9

data @0, 4


goto start

on interrupt goto tiempo

start:
OPTION_REG = %10000111
INTCON = %10100000
read 0, circunferencia
goto main

main:

if portb.2 = 0 then gosub setup

if intcon.1 = 1 then
pulsos = pulsos + 1
intcon.1 = 0 ; pongo a 0 el flag de la interrupcion en Rb0
endif

if cuenta = 4 then
cuenta = 0
velocidad = pulsos * circunferencia * 100
velocidad = velocidad / 25
velocidad = velocidad * 36
velocidad = velocidad / 40
x = velocidad
pulsos = 0
endif

gosub display

goto main


display:
num = x dig 0 ; unidad de X y lo manda a num
porta = num
high t1
pause 3
low t1
num = x dig 1 ; decena de X y lo manda a num
porta = num
high t2
pause 3
low t2
num = x dig 2 ; centena de X y lo manda a num
porta = num
high t3
pause 3
low t3
return



disable
setup: ; config setup

x = circunferencia
for demora = 1 to 50
gosub display
next

setup1:
x = circunferencia
for demora = 1 to 20
gosub display
next
if portb.2 = 0 then gosub config
if portb.3 = 0 then
intcon.7 = 0
write 0,circunferencia
intcon.7 = 1
if eecon1.3 = 0 then ; if write ok shows 888
x = 888
for demora = 1 to 30
gosub display
next
endif
if eecon1.3 = 1 then ; if write not ok shows 111
x = 111
for demora = 1 to 30
gosub display
next
endif
return ; si se apreta el segundo boton vuelve a main
enable
endif
goto setup1

config:

circunferencia = circunferencia + 1
if circunferencia = 216 then circunferencia = 0

return

disable
tiempo:

cuenta = cuenta + 1

TMR0 = timer
INTCON.2 = 0

resume
enable