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.

keil problem with serial eeprom

Status
Not open for further replies.

hassan ali

Member level 2
Joined
May 18, 2010
Messages
47
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
egypt
Activity points
1,667
hi , sorry for my English.....
i have already build my own firmware for interfacing serial eeprom with 8051 but am facing i problem and i can't know it , i made the HEX file but on simulation if i store (ex:#05h) the out put then after storing this reading inside the eeprom and read it again became wrong always the out put is (ex:0xff) i tried a lot of different serial eeprom with different codes but always facing this problem so i gues that the problem is not in firmware may be there is a header file i must add it in keil at programming
note: am using assembly code

and also there is a message form keil
*** WARNING L2: REFERENCE MADE TO UNRESOLVED EXTERNAL
 

post your code?? controller part number and the serial eeeprom used for testing your program.... You cannot simulate eeprom conditions in keil... you need a hardware to do it.....
 

the mu ix at8051 and using serial eeprom 24c02
and here is my code
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

WTCMD EQU 10100110B ;WRITE DATA COMMAND Note 3
RDCMD EQU 10100111B ;READ DATA COMMAND Note 3
SDA1 EQU P2.1 ;SDA=PIN5
SCL1 EQU P2.0 ;SCL=PI

STORE:
MOV A,#WTCMD ;LOAD WRITE COMMAND
CALL OUTS ;SEND IT
MOV A,R4 ;GET LOW BYTE ADDRESS
CALL OUT ;SEND IT
BTLP: MOV A,R1 ;GET DATA

CALL OUT ;SEND IT
;INCREMENT DATA POINTER
;LOOP TILL DONE
CALL STOP ;SEND STOP CONDITION
RET

OUT: MOV R2,#8 ;LOOP COUNT -- EQUAL TO BIT COUNT
OTLP: RLC A ;SHIFT BIT
JNC BITL
SETB SDA1 ;DATA = 1
JMP OTL1 ;CONTINUE
BITL: CLR SDA1 ;DATA = 0
OTL1: SETB SCL1 ;CLOCK HI
NOP ;NOTE 1
NOP
NOP
NOP
NOP

CLR SCL1 ;CLOCK LOW
DJNZ R2,OTLP ;DECREMENT COUNTER
SETB SDA1 ;TURN PIN INTO INPUT
NOP ;NOTE 1
NOP
NOP
SETB SCL1 ;CLOCK ACK
NOP ;NOTE 1
NOP
NOP
NOP
NOP

CLR SCL1
RET


STOP: CLR SDA1 ;STOP CONDITION SET DATA LOW
NOP ;NOTE 1
NOP
NOP
NOP
NOP

SETB SCL1 ;SET CLOCK HI
NOP ;NOTE 1
NOP
NOP
NOP
NOP

SETB SDA1 ;SET DATA HIGH
RET


OUTS: MOV R2,#8 ;LOOP COUNT -- EQUAL TO BIT COUNT
SETB SDA1 ;INSURE DATA IS HI
SETB SCL1 ;INSURE CLOCK IS HI
NOP ;NOTE 1
NOP
NOP
NOP
NOP
CLR SDA1 ;START CONDITION -- DATA = 0
NOP ;NOTE 1
NOP
NOP
NOP
NOP
CLR SCL1 ;CLOCK = 0
OTSLP: RLC A ;SHIFT BIT
JNC BITLS
SETB SDA1 ;DATA = 1
JMP OTSL1 ;CONTINUE
BITLS: CLR SDA1 ;DATA = 0
OTSL1: SETB SCL1 ;CLOCK HI
NOP ;NOTE 1
NOP
NOP
NOP
NOP

CLR SCL1 ;CLOCK LOW
DJNZ R2,OTSLP ;DECREMENT COUNTER
SETB SDA1 ;TURN PIN INTO INPUT
NOP ;NOTE 1
NOP
NOP
SETB SCL1 ;CLOCK ACK
NOP ;NOTE 1
NOP
NOP
NOP
NOP

CLR SCL1
RET


READ:
MOV A,#WTCMD ;LOAD WRITE COMMAND TO SEND ADDRESS
CALL OUTS ;SEND IT
MOV A,R4 ;GET LOW BYTE ADDRESS
CALL OUT ;SEND IT
CALL CREAD ;GET DATA BYTE
MOV P1,R3
RET

CREAD: MOV A,#RDCMD ;LOAD READ COMMAND
CALL OUTS ;SEND IT
CALL IN ;READ DATA
MOV R1,A ;STORE DATA
CALL STOP ;SEND STOP CONDITION
MOV B,R1
MOV R3,B
RET


IN: MOV R2,#8 ;LOOP COUNT
SETB SDA1 ;SET DATA BIT HIGH FOR INPUT
INLP: CLR SCL1 ;CLOCK LOW
NOP ;NOTE 1
NOP
NOP
NOP
NOP ;NOTE 2
NOP
SETB SCL1 ;CLOCK HIGH
CLR C ;CLEAR CARRY
JNB SDA1,INL1 ;JUMP IF DATA = 0
CPL C ;SET CARRY IF DATA = 1
INL1:RLC A ;ROTATE DATA INTO ACCUMULATOR
DJNZ R2,INLP ;DECREMENT COUNTER
CLR SCL1 ;CLOCK LOW
RET
 

change the eeprom and test again........ May be the batch problem..... try to simulate it in proteus to see if the code works fine or not.....

refer 8052.com - The Online 8051/8052 Microcontroller Resource - 8052.com
they have a code bundle which has sample programs.... or search the forum, it has beeen answered many times......
 

i have already change the eeprom and change the code ,
but did u find any wrong in my code ????
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top