This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Using AT24c02 for random read operation

I had written a ASM code for Driving a EEPROM using P89V51RD2...........
It works fine for sequential write n read....
But the problem is, tat it doesnt read for random..... Plz hep me in tat...
I have placed my code.....

pre SDA equ P1.0 SCL equ P1.1

WRITE equ 10100000B READ equ 10100001B

ORG 0H

MOV SCON,#50H ; Configuration for Reception of Serial Port MOV TMOD,#20H MOV TH1,#-3 ; Set the Baud Rate 9600 SETB TR1

;Store a byte "data" in location "addr" in EEPROM

MOV 10H,#50H ; ADDR= "10H" DATA= "50H" MOV A,#WRITE CALL SENDS MOV A,10H CALL SEND MOV A,10H MOV R7,A CALL SEND CALL STOP MOV A,R7 CALL DISPLAY

;Read the data frm EEPROM

MOV A,#WRITE CALL SENDS MOV A,#10H CALL SEND ;MOV A,10H CALL READ1 ;CALL STOP MOV A,R7 CALL DISPLAY ;CALL DELAY

SENDS: MOV R5,#08H SETB SDA SETB SCL NOP NOP CLR SDA NOP NOP CLR SCL
RETURN: RLC A JNC NEXT SETB SDA JMP ROW
NEXT: CLR SDA
ROW: SETB SCL NOP NOP CLR SCL DJNZ R5,RETURN NOP NOP CLR SCL MOV A,P1 SETB SCL NOP NOP JNB SDA,down MOV A,#4EH ;CALL DISPLAY RET down: MOV A,#41H ;CALL DISPLAY RET

SEND: MOV R4,#08H
RETURN1: RLC A JNC NEXT1 SETB SDA JMP ROW1
NEXT1: CLR SDA
ROW1: SETB SCL NOP NOP CLR SCL DJNZ R4,RETURN1 ;CALL DISPLAY NOP NOP CLR SCL MOV A,P1 JNB SDA, down1 MOV A,#4EH ;CALL DISPLAY RET down1: MOV A,#42H ;CALL DISPLAY RET

READ1: MOV A,#READ CALL SENDS CALL IN ;MOV R7,A CALL STOP RET

IN: MOV R6,#08H SETB SDA
IN2: CLR SCL NOP NOP CLR P1.7 /*CALL DELAY SETB P1.7 CALL DELAY*/ SETB SCL CLR C ;JNB SDA,IN1 ;CPL C MOV C,SDA
IN1: RLC A DJNZ R6,IN2 MOV R7,A ;CALL DISPLAY NOP NOP CLR SCL NOP NOP MOV A,P1 SETB SCL JNB SDA,down2 MOV A,#4EH CALL STOP ;CALL DISPLAY RET down2: MOV A,#43H ;CALL DISPLAY CALL STOP RET

STOP: CLR SDA NOP NOP SETB SCL NOP NOP SETB SDA RET

DELAY: MOV R0,#02H
HERE2: MOV R1,#0A0H
HERE1: MOV R2,#0A0H
HERE: DJNZ R2,HERE DJNZ R1,HERE1 DJNZ R0,HERE2 RET

DISPLAY: MOV SBUF,A
CONT: JNB TI,CONT CLR TI RET
END /pre

Parents
  • 1) Are you sure that you selected the correct architecture when posting? Is the P89V51RD2 really a '251 and not a '51 chip?

    2) Are you sure that you remembered to read the posting instructions for source code directly above the message box?

    3) Do you think anyone can read your code, as currently formatted?

Reply
  • 1) Are you sure that you selected the correct architecture when posting? Is the P89V51RD2 really a '251 and not a '51 chip?

    2) Are you sure that you remembered to read the posting instructions for source code directly above the message box?

    3) Do you think anyone can read your code, as currently formatted?

Children
No data