Hi Emavil. This is a snippet of code I use with a 16F872 with eeprom. In case of power interruption it will go back to the mode it was in. The line at the top "IF MODE > 2 Then LET MODE = 0" is only valid with a newly programmed PIC. Once a write is performed, it will read a 0 or 1 or 2. Hope this helps.
address VAR WORD 'address variable
TRISA = %00110000
TRISB = %11111101
TRISC = %00000000
Read 1,MODE
IF MODE > 2 Then LET MODE = 0
START:
MAIN PROGRAM HERE
CHANGEMODE:
LET MODE = (MODE + 1) 'ADVANCE MODE
IF MODE > 2 Then LET MODE = 0
Write 1,MODE
GoTo START




Bookmarks