hi...m harjeev... m trying to interface eeprom (24c256) with AT89s52 but its not working... i don't knw where is the prob.. plz help me..may code is here...i have also interfacing lcd to it.. ;Er. Harjeev Sharma ; Best of luck ; ;****************************************************************** RS BIT P2.5 ;rs bit of lcd RW BIT P2.4 ;rw bit of lcd E BIT P2.3 ;enable bit of lcd FL BIT P0.7 ; flag bit of lcd LCD EQU P0 scl bit p2.0 ;serial clk of eeprom sda bit p2.1 ;serial data of eeprom C1 EQU 31H C2 EQU 32H C3 EQU 33H ORG 00H START: setb scl setb sda
MOV LCD,#00H
MOV C1,#0 MOV C2,#0 MOV C3,#0
MOV A,#38H ;2*16 MATRIX ACALL COMMAND MOV A,#38H ;2*16 MATRIX ACALL COMMAND MOV A,#38H ;2*16 MATRIX ACALL COMMAND MOV A,#02 ;RETURN HOME ACALL COMMAND MOV A,#01 ;CLEAR DISPLAY SCREEN ACALL COMMAND MOV A,#0CH ;DISPLAY ON CURSOR OFF ACALL COMMAND MOV A,#80H ;MOVE CURSOR TO FIRST LINE SECOND COLOUMN ACALL COMMAND MOV DPTR,#TABLE1 ;DISPLAY ERP ACALL DISPLAY
setb scl setb sda acall five_delay acall eeprom_start mov a,#0a0h acall eeprom_write mov a,#01h acall eeprom_write mov a,#01h acall eeprom_write mov a,#11 acall eeprom_end acall delay
mov a,#0cfh acall command mov a,#'o' acall write
;;;;;;;;;;;;;;; READ ;;;;;;;;;;;;;;;;; acall eeprom_start mov a,#0a0h acall eeprom_write mov a,#01h acall eeprom_write mov a,#01h acall eeprom_write
clr scl acall eeprom_start mov a,#0a1h acall eeprom_write clr a acall eeprom_read acall eeprom_end
jmp $
eeprom_write: mov 75h,a setb scl error: mov a,75h mov r2,#08 uu: clr c clr scl rlc a jc zz clr sda jmp yy zz: setb sda yy: acall five_delay setb scl acall five_delay djnz r2,uu clr scl acall five_delay setb scl acall five_delay jnb sda,er mov a,#0c7h acall command mov a,#'E' acall write jmp error er: mov a,#0c7h acall command mov a,#' ' acall write ret
eeprom_read: mov r3,#08 nnm: clr c
clr scl setb sda ; make input pin acall five_delay
setb scl acall five_delay jnb sda,qq setb c jmp ww qq: clr c ww: nop rlc a mov 80h,a djnz r3,nnm ; mov 80h,a mov a,#0c0h acall command mov a,80h acall htd acall out1 clr scl acall five_delay setb scl acall five_delay ret
eeprom_start: setb sda acall five_delay setb scl acall five_delay clr sda acall five_delay ret eeprom_end: setb scl acall five_delay clr sda acall five_delay setb sda acall five_delay ret
five_delay: mov r6,#0 xxh: mov r7,#1 djnz r7,$ djnz r6,xxh ret
HTD: ;CONVERT HEX(BINARY) TO ASCII MOV B,#10 DIV AB MOV C1,B MOV B,#10 DIV AB MOV C2,B MOV C3,A RET OUT1: MOV A,C3 ORL A,#30H ACALL WRITE MOV A,C2 ORL A,#30H ACALL WRITE MOV A,C1 ORL A,#30H ACALL WRITE ret
LCDCLR: MOV A,#01H ;CLEAR DISPLAY SCREEN ACALL COMMAND RET ; DISPLAY DATA ON LCD DISPLAY: CLR A MOVC A,@A+DPTR JZ NEXT ACALL WRITE INC DPTR JMP DISPLAY NEXT: RET WRITE: ACALL CHKBUSY MOV LCD,A SETB RS CLR RW SETB E acall delay CLR E RET COMMAND: ACALL CHKBUSY MOV LCD,A CLR RS CLR RW SETB E acall delay CLR E RET CHKBUSY: SETB FL SETB RW CLR RS CHECK4: CLR E SETB E JB FL,CHECK4 RET delay1: MOV R4,#255 AGAIN22: MOV R5,#1 BACK22: DJNZ R5,BACK22 DJNZ R4,AGAIN22 RET DELAY: MOV R6,#255 AGAIN: MOV R7,#255 BACK: DJNZ R7,BACK DJNZ R6,AGAIN RET TABLE1: DB 'write ',0 TABLE2: DB 'read',0 TABLE3: DB 'error',0 end
may code is here
that is not code, code is indented and commented.
asking to have someone for free figure out uncommented non-indented scribbles is not likely to produce results.
Erik
Thanx erik...can u plz send me a exact code...
Thanx erik...can u plz send me a exact code
"u plz" write in English?
this forum is not a 'code provider' it is intended to help you with YOUR code. make YOUR code legible and ask specific questions
The process of finding the problem is known as Debugging. It is an essential part of the development process.
What Debugging have you done?
Debugging tips: www.8052.com/.../120313 www.8052.com/.../169331
okies... when I am reading from EEPROM then its read 0ffh...although i am generating all clock pulses .....
... providing formatted, commented code is futile, why do you persist?
"when I am reading from EEPROM then its read 0ffh... although i am generating all clock pulses"
OK, so there's an observation - that's a start.
Next, think about what things might cause that...
Again, see: www.8052.com/.../120313
Remember that this is not purely a software task - the software and the hardware both need to be correct for this to all work!
You say you are "generating all clock pulses" - have you verified that the signals on the clock wire are correct?
Your source text is a mess. Go through it carefully, laying it out clearly, and commenting what it is doing. This process alone will often reveal errors in the source code - so do not skimp on it!
And, once your code is legible and well-commented, other people will be more inclined to look at it.
Atmel has many application notes with sample code for interfacing EPROMS and EEPROMs.
www.atmel.com/.../products
Bradford
HEY Harjeev Sharma. NICE CODE MAN. I WANT CODE FOR A 24C256 TO. when you fix the code post it to me coz i can use it. i want it. and i wand lcd too.
Nice code? Sorry, but it doesn't sound like you have the skills to see if it is nice or not. It sounds like your skills is in trying to get someone else to supply you with code for your school assignments.
when you fix the code post it to me coz i can use it.
I suggest Harjeev Sharma send you a quote