Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Helllllp .. Problem with a simple EEPROM in F84A program

Status
Not open for further replies.

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
 

Re: Helllllp .. Problem with a simple EEPROM in F84A progra

try movw command here
you cannot movlw as this is for the last byte not the value you set with the command
this is the next value
and you would need a movwf to move this byte from the w register



best is write a little flow chart and test each function separate

personaly c code is far more reliable so look for a c compiler

try sdcc this is free and works for this chip
its quick to learn and works much easier than asm


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
 

Re: Helllllp .. Problem with a simple EEPROM in F84A progra

Thanks for help ..but i found the problem in my code .. it is simply that i didn't move to the required BANK that contains the EEADR register ..
the program worked good when i did this ...
I hope this helps somepeople ..
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top