Code:
'My Tested Prototype with Pic18F4550 and EEPROMInclude "modedefs.bas"
INCLUDE "C:\PBP\USB18\EE_Vars.pbp" ; Include the EE_var routines
asm
__CONFIG _CONFIG1L, _PLLDIV_5_1L & _CPUDIV_OSC1_PLL2_1L & _USBDIV_2_1L
__CONFIG _CONFIG2L, _PWRT_ON_2L & _BOR_ON_2L & _BORV_2_2L & _VREGEN_ON_2L
__CONFIG _CONFIG2H, _WDT_OFF_2H
__CONFIG _CONFIG3H, _MCLRE_ON_3H & _LPT1OSC_OFF_3H & _PBADEN_OFF_3H & _CCP2MX_ON_3H
__CONFIG _CONFIG4L, _STVREN_ON_4L & _LVP_OFF_4L & _ICPRT_OFF_4L & _XINST_OFF_4L & _DEBUG_OFF_4L
endasm
DEFINE OSC 48
ADCON1 = 15 ' Set all I/Os to Digital
CMCON = 7 ' Disable Comparators
INTCON2.7 = 0
'EEprom data
'U1 VAR WORD : @ EE_var _U1, WORD, 9999 ' for later use
DATA @0,5,"12345"
DATA @6,5,"54321"
DATA @13,5,"14332"
DATA @19,5,"24432"
DATA @25,5,"85921"
TRISA = %00000000
TRISD = %00000000
PORTD = %00000000
TRISB = %11110000 ' Set Keypad I/O
PORTB = 0 ' Set columns LOW
PortA = 0
myvarkey var byte
ByteA var Byte[6]
B0 var byte[5]
cnt var byte
x var byte
cnt = 0
asciichar var byte
address var byte
' ---------------------------------[Program Start]----------------------------------------------
serout2 PortD.5,T9600,[$1B,$63,$30]
pause 200
serout2 PortD.5,84,[$1B,$45,"EEPROM"]
serout2 PortD.5,84,[$D,"Studies"]
serout2 PortD.5,84,[$1B,$63,$30]
pause 2000
Serout2 PortD.5,84, [$1B,$45]
main:
@ READKEYPAD _myvarkey
lookup myvarkey,[0,"123A456B789C*0#D"],Key
Serout2 PortD.5,84, [$1B,$45,"Key = ",Key]
if Key = "#" and cnt < 6 then
if ByteA[0]="1" and ByteA[1]="9" then ' wait 19 is pressed before updating
Serout2 PortD.5,84, [$D, "Special Key"]
pause 20
serout2 PortD.5,84,[$D,str ByteA\cnt]
READ 6,x
for address=6 to x+6
Write address+1, ByteA[address]
next address
cnt=0
endif
else
ByteA[cnt]=Key
Serout2 PortD.5,84, [$D, ">" , ByteA[cnt]]
cnt=cnt+1
Endif
if cnt > 5 then
Serout2 PortD.5,84, [$D, "5Digits only"]
cnt = 0
ENdif
if Key = "A" then
READ 0,x
serout2 PortD.5,84,[$D,Dec x," "]
pause 1000
for address=0 to x
READ address,asciichar
serout2 PortD.5,84,[$D,asciichar]
next address
pause 1000
cnt = 0
endif
if Key = "B" then
READ 6,x
serout2 PortD.5,84,[$D,Dec x," "]
pause 1000
for address=0+6 to x+6
READ address,asciichar
serout2 PortD.5,84,[$D,asciichar]
next address
pause 1000
cnt = 0
endif
if Key = "C" then
READ 13,x
serout2 PortD.5,84,[$D,Dec x," "]
pause 1000
for address=0+13 to x+13
READ address,asciichar
serout2 PortD.5,84,[$D,asciichar]
next address
pause 1000
cnt = 0
endif
if Key = "D" then
READ 19,x
serout2 PortD.5,84,[$D,Dec x," "]
pause 1000
for address=0+19 to x +19
READ address,asciichar
serout2 PortD.5,84,[$D,asciichar]
next address
pause 1000
cnt = 0
endif
if Key = "*" then
READ 25,x
serout2 PortD.5,84,[$D,Dec x," "]
pause 1000
for address=0+25 to x +25
READ address,asciichar
serout2 PortD.5,84,[$D,asciichar]
next address
pause 1000
cnt = 0
endif
pause 500
goto main
But updating Data @0 ,"12345" was not a problem, I'm stuck passed @0 location.
Bookmarks