ahmad_abdulghany
Advanced Member level 4
- Joined
- Apr 12, 2005
- Messages
- 1,206
- Helped
- 102
- Reputation
- 206
- Reaction score
- 22
- Trophy points
- 1,318
- Location
- San Jose, California, USA
- Activity points
- 11,769
I wrote the following assembly program to the MPLab to test the EEPROM operation, and i wrote it to check that the value : 0xAA is stored first to a GPR called DATA1, then it is been copied to the EEDATA then stored to the EEPROM memory location 0x01 ..
after that i made simple delay .. then read out this EEPROM address content, then store it into another GPR called DATA2
After excecution of this simple program .. i think the DATA2 contents must be the same as the DATA1 contents .. but this didn't happen .. i don't know what is the promblme ..
note that it is the first time i use the EEPROM operation.. and it is very urgent to me to do certain project that its deadtime is tomorrow .. please help out immidiately ..
thank you very much..
here you are the program :
; ====================================================
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _XT_OSC
;***** VARIABLE DEFINITIONS
DATA1 EQU 0X20
DATA2 EQU 0X21
DELAY EQU 0X23
;*******************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
main
; remaining code goes here
; WRITE OPERATION TO EEPROM
;***************************
MOVLW 0X01
MOVWF EEADR ; ADDRESS IS NOW IN THE ADDRESS REG
MOVLW 0XAA
MOVWF DATA1
MOVFW DATA1
MOVWF EEDATA ; DATA THAT IS TO BE WRITTEN
BANKSEL INTCON
BCF INTCON,GIE ; DISABLE INTERRUPTS
BANKSEL EECON1
BSF EECON1,WREN ; ENABLE WRITE
; NEXT LINES ARE FIXED :
;***********************
MOVLW 0X55
MOVWF EECON2
MOVLW 0XAA
MOVWF EECON2
BSF EECON1,WR ; STARTS TO WRITE
BANKSEL INTCON
BSF INTCON,GIE ; RE-ENABLE INTERRUPTS
; SIMPLE DELAY
MOVLW 0XFF
MOVWF DELAY
LOOP1
DECFSZ DELAY
GOTO LOOP1
MOVLW 0XFF
MOVWF DELAY
LOOP2
DECFSZ DELAY
GOTO LOOP2
MOVLW 0XFF
MOVWF DELAY
LOOP3
DECFSZ DELAY
GOTO LOOP3
; READ OPERATION
;*****************
MOVLW 0X01
MOVWF EEADR ; ADDRESS OF DATA TO BE READ
BANKSEL EECON1
BSF EECON1,RD ; ENABLE READ CONTROL
MOVFW EEDATA ; AS EEDATA CONTAINS DATA OF EEPROM
; ADDRESS SPECIFIED
MOVWF DATA2
END
after that i made simple delay .. then read out this EEPROM address content, then store it into another GPR called DATA2
After excecution of this simple program .. i think the DATA2 contents must be the same as the DATA1 contents .. but this didn't happen .. i don't know what is the promblme ..
note that it is the first time i use the EEPROM operation.. and it is very urgent to me to do certain project that its deadtime is tomorrow .. please help out immidiately ..
thank you very much..
here you are the program :
; ====================================================
list p=16F84A ; list directive to define processor
#include <p16F84A.inc> ; processor specific variable definitions
__CONFIG _CP_OFF & _WDT_OFF & _PWRTE_OFF & _XT_OSC
;***** VARIABLE DEFINITIONS
DATA1 EQU 0X20
DATA2 EQU 0X21
DELAY EQU 0X23
;*******************************************************************
ORG 0x000 ; processor reset vector
goto main ; go to beginning of program
main
; remaining code goes here
; WRITE OPERATION TO EEPROM
;***************************
MOVLW 0X01
MOVWF EEADR ; ADDRESS IS NOW IN THE ADDRESS REG
MOVLW 0XAA
MOVWF DATA1
MOVFW DATA1
MOVWF EEDATA ; DATA THAT IS TO BE WRITTEN
BANKSEL INTCON
BCF INTCON,GIE ; DISABLE INTERRUPTS
BANKSEL EECON1
BSF EECON1,WREN ; ENABLE WRITE
; NEXT LINES ARE FIXED :
;***********************
MOVLW 0X55
MOVWF EECON2
MOVLW 0XAA
MOVWF EECON2
BSF EECON1,WR ; STARTS TO WRITE
BANKSEL INTCON
BSF INTCON,GIE ; RE-ENABLE INTERRUPTS
; SIMPLE DELAY
MOVLW 0XFF
MOVWF DELAY
LOOP1
DECFSZ DELAY
GOTO LOOP1
MOVLW 0XFF
MOVWF DELAY
LOOP2
DECFSZ DELAY
GOTO LOOP2
MOVLW 0XFF
MOVWF DELAY
LOOP3
DECFSZ DELAY
GOTO LOOP3
; READ OPERATION
;*****************
MOVLW 0X01
MOVWF EEADR ; ADDRESS OF DATA TO BE READ
BANKSEL EECON1
BSF EECON1,RD ; ENABLE READ CONTROL
MOVFW EEDATA ; AS EEDATA CONTAINS DATA OF EEPROM
; ADDRESS SPECIFIED
MOVWF DATA2
END