Are there any PIC microcontroller programmers here?
I'm learning some PIC microcontroller programming using a pickit2 and the 16F887 chip I'm working through trying out the various facilities at the moment. I can't able to read right byte from location. I am sharing my read and write code. Did lot of combination / read lot of data on net and sheet but not able to close this issue. My code for read:
EDREAD
BANKSEL EEADR
movlw 0X08 ;Read data from location 08
movwf EEADR
BANKSEL EECON1
bcf EECON1,EEPGD
bsf EECON1,RD
BANKSEL EEDATA
movf EEDATA,W
BANKSEL BIN1
movwf BIN1
RETURN
Write Instruction:
EDWRITE
banksel EECON1
back btfsc EECON1,WR ;Wait for
goto back
banksel EEADR
movlw 0X08
BANKSEL EEADR
movwf EEADR
BANKSEL VALUE
movf VALUE,W
BANKSEL EEDATA
movwf EEDATA
NOP
NOP
BANKSEL EECON1
bcf EECON1,EEPGD
bsf EECON1,WREN
banksel EECON2
MOVLW 0x55 ; Unlock-write voodoo
MOVWF EECON2
MOVLW 0xAA
MOVWF EECON2
BANKSEL EECON1
BSF EECON1,WR
JUMP BTFSC EECON1,WR ;
GOTO J UMP
BCF EECON1,WREN
RETURN
i write data in value resistor to EEPROM. This data comes from ADC Input value. data shown post running code is 255 despite input of ADC varies from 100 to 200.