Hello all,

I am trying to write and read from memory of PIC18F14k50.I have following code to write to memory location $500:
Code:
DEFINE OSC 24
 
X var byte
Y var word
Value var byte



mainloop:    
Pause 4000      
Y = $500 
Value=2
                                                       
erasecode Y                                   
for X = 1 to 16                                 
writecode Y, Value                         
Y = Y + 1                                       
next X
   
   Goto mainloop

I am trying to read from same location and turn LED on if 2 is stored at address $500.

Code:
DEFINE OSC 24 

TRISC.4 = 0
LED VAR PORTC.4 
X var byte
Y var word
Value var byte

mainloop:

readcode $500, Value 
   If Value = 2 Then 
      HIGH LED   
      goto  ledout
      Pause 50
   Else
      LOW LED    
      Pause 50
   Endif
   Goto mainloop

However It doesn't turn on the LED.Any thoughts?

Thanks