Write and Read from eeprom
I have the below code (one part of code).
My problem is when turn off the power and after turn on again , don't save the value P in the eeprom always.Why;
I use 16f88
Code:
P VAR WORD 'value of the divider
FLAG VAR BYTE
READ 3,FLAG
IF FLAG = 55 THEN
READ 1,P.BYTE0 ' Divider
READ 2,P.BYTE1
ELSE
P= 256 ' value of the divider
ENDIF
..
..
..
..
..
'************************** CHOICE OF THE DIVIDER ***********************
PREDIV:
LCDOUT $FE,1,"* DIVIDER *"
LCDOUT $FE,$C0," P = ",#P
LOOP:
BUTTON PLUS,0,10,5,B1,1,PICK ' Goes to PICK if press the button
BUTTON BMENU,0,255,0,B4,1,MEN
PAUSE 100
GOTO LOOP
PICK:
IND = IND + 1
IF IND< 9 THEN CHOIX
IND= 0
GOTO CHOIX
CHOIX:
LOOKUP2 IND,[1,10,16,32,40,64,80,128,256],P
WRITE 3 , 55
WRITE 1 , P.BYTE0 ' SAVE The VALUE OF P
WRITE 2 , P.BYTE1
PAUSE 100
GOTO MAIN
BigWumpus's was right !!!
Yep that is my problem.
if I take out the "write" it saves fine
COINOUT100:
PREMIOS=PREMIOS+1:if total > 0 then TOTAL=TOTAL-1
:GOTO LOOP 'GOSUB WRITEIT
So I did a little checking and the machine I'm interfacing to sends several signals as its lossing power, somthing to do with a cheap design cause theres no other reason. I will buy a scope to see if its a specific signal or just random crap. I think its just random crap cuase if I hook a anolog counter to it, it counts up to differrent amounts somtime 3 somtimes up to 6.
As to my messy code design, I'm sorry skimask. I have never had any training of any kind nor has anyone ever showed me how to write decent code. This is the first time in 15 years I have ever been on a forum for basic, quickbasic, visual basic, or pic basic pro.
I am one to learn things on my own, but as you pointed out (at my messy code) that type of learning has its problems. I do my best
I will continue this forum experience, Its al right. thank you all for your help with this one.
And thank you BigWumpus for figuring this one out for me......