
Originally Posted by
Darrel Taylor
Unfortunately, some bootloaders have chosen to "erase" EEPROM values to 0 instead of the $FF done by hardware. This can be problematic. As long as you know which way your programmer works, it's a definite possibility.
Hi Darrel,
Thanks for your most welcomed input as it got me thinking on the right path (I'm hoping). I haven't checked yet if my pickit 2 programmer erases the EEPROM values to 0 or 255 when programming but with the code below it wouldn't really matter. I haven't tried this work a round yet but I can't think of any reasons why it wouldn't work.
Thanks Again
jessey
Code:
'(2) PIC Config Fuse Definitions for 16f688
@ __config _INTRC_OSC_NOCLKOUT & _WDT_ON & _MCLRE_OFF & _CP_OFF & _BOD_ON
@ ERRORLEVEL -306
' Data for house and unit codes
housetbl data $60,$70,$40,$50,$80,$90,$A0,$B0,$E0,$F0,$C0,$D0
data $00,$10,$20,$30
unittbl data 0,$10,$8,$18,$40,$50,$48,$58
EEPROMData94 var BYTE
Set_Point VAR EEPROMData94
READ 94, EEPROMData94
IF Set_Point = 255 THEN
Set_point = 150 ' Set a default value
EEPROMData94 = Set_Point
Write 94, EEPROMData94
ENDIF
IF Set_Point = 0 THEN
Set_point = 150 ' Set a default value
EEPROMData94 = Set_Point
Write 94, EEPROMData94
ENDIF
GOTO Mainloop
My set point doesn't ever need to be set to 0 or 255 in my program and this routine would prevent the user from setting either of the two there.
Code:
Adjust_The_Set_Point:
Loop1:
IF Push_Button1 = Is_Pressed THEN
IF Set_Point < 255 THEN Set_Point = Set_Point + 1 : Save_Var = Yes
IF Set_Point > 254 THEN Set_Point = 254 ' 255 is not allowed
ENDIF
IF Push_Button2 = Is_Pressed THEN
Set_Point = Set_Point - 1 : Save_Var = Yes
IF Set_Point < 2 THEN Set_Point = 1 ' 0 is not allowed
ENDIF
IF Push_Button1 = Is_Not_Pressed THEN
IF Push_Button2 = Is_Not_Pressed THEN
RETURN
ENDIF
ENDIF
Pause 100
GOSUB Update_The_Lcd ' just in case a button is held down
IF a = 0 THEN Loop1 ' a always equals zero, use instead of GOTO...
RETURN
Bookmarks