Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

24c32a serial memory

Status
Not open for further replies.

aamir1

Member
Hi guyz i have the code for the memory 24c04a i want to convert it to 24c32a where should i do the required modifications please let me know i am working on it since 1 week. i have written the code below. reply soon

Code:
;RAM LOCATION USED IN THIS MODULE 70H

WTCMD 	EQU 10100000B		;24C04 WRITE COMMAND
RDCMD 	EQU 10100001B		;24C04 READ COMMAND
ADDRS	EQU 70H

SCL 	EQU P3.6		;SERIAL CLOCK PIN
SDA 	EQU P3.7		;SERIAL DATA PIN

	ORG 0000H
	LJMP START
	ORG 0030H
START:
	MOV P1,#01H
	MOV R1,#55H		;
	MOV A,#00		;WRITE THE DATA IN R1 REGISTER INTO
	MOV ADDRS,A		;ADDRESS POINTED BY ADDRS INTO TEH 24C04
	LCALL WRITE		;
	LCALL L_DELAY

	MOV A,#00		;
	MOV ADDRS,A		;READ THE DATA FROM 24C04 FROM THE MEMORY
	LCALL READ		;LOCATION POINTED BY ADDRS AND STORE IN R2
	MOV A,R2		;

	MOV P1,A		;MOVE THE RED BACK DATA ONTO P0

	LCALL L_DELAY

	LJMP START


;THIS IS USED TO WRITE INTO 24C04
;ARGUMENTS1 --> ADDRS => ADDRESS TO BE WRITTEN INTO,IN 24C04 MEMORY
;ARGUMENTS2 --> R1 ==> DATA TO BE WRITTEN
;RETURN  --> NONE

WRITE:
	MOV A,#WTCMD
	CALL OUTS

	MOV A,ADDRS
	CALL OUT

	MOV A,R1
	CALL OUT
	CALL STOP
	RET

;THIS SUB ROUTINE IS USED TO READ DATA FROM THE 24C04
;ARGUMENTS --> ADDRS ==> ADDRESS IN 24C04,THE DATA SHOULD BE READ FROM.
;RETURN --> R2(DATA THAT WAS READ)
READ:
	MOV A,#WTCMD
	CALL OUTS

	MOV A,ADDRS
	LCALL OUT

	MOV A,#RDCMD
	LCALL OUTS

	LCALL IN
	MOV R2,A
	LCALL STOP
	RET

OUTS:
	MOV B,#8
	SETB SDA
	SETB SCL
	NOP
	CLR SDA
	NOP
	CLR SCL
OSLOOP:
	RLC A
	MOV SDA,C
	SETB SCL
	NOP
	CLR SCL
	DJNZ B,OSLOOP
	SETB SDA
	NOP
	SETB SCL
	NOP
	CLR SCL
	RET

OUT:
	MOV B,#8
OLOOP:
	RLC A
	MOV SDA,C
	SETB SCL
	NOP
	CLR SCL
	DJNZ B,OLOOP
	SETB SDA
	NOP
	SETB SCL
	NOP
	CLR SCL
	RET

IN:
	MOV B,#8
	SETB SDA
INLOOP:	CLR SCL
	NOP
	SETB SCL
	MOV C,SDA
	RLC A
	DJNZ B,INLOOP
	CLR SCL
	RET

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

DLAYms:	MOV R6,#150
	MOV B,#00
MS1:	DJNZ B,$	;((2*255)+(2*255)*150
	DJNZ B,$	;=153 MILLI SECONDS
	DJNZ R6,MS1
	RET

L_DELAY:	MOV R7,#0AH	;153 MILLISECONDS * 10
LLL:	LCALL DLAYms	;1.53 SECONDS
	DJNZ R7,LLL
	RET
	END
 
Last edited by a moderator:
The biggest difference between the chips is the size of the address bus. On the 04 the address is 9 bits long and on the 32 it's 12. If you look at section 5 of these data sheets 24LC04 and 24LC32 (don't worry about the LC bit) you'll see what I mean.

To change the code you need to send an additional byte after the first address byte. Note that the above code can only access the first 256 bytes of the 512 available.

I'm not familiar with 8051 but I would guess you would make ADDRS a word and then do,
Code:
WRITE:
    MOV A,#WTCMD
    CALL OUTS

    MOV A,ADDRS
    CALL OUT

    MOV A,ADDRS+1
    CALL OUT

    MOV A,R1
    CALL OUT
    CALL STOP
    RET
and a similar thing to the read function.

Mike.
 
Good to hear that you succeeded, well done.

Also, thanks to "The moderation team" for codifying the first post. Is that an auto thing like my code tidy?

Mike.
 
Status
Not open for further replies.

Latest threads

Back
Top