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.

I2c interface in eeprom with microcontroller

Status
Not open for further replies.

1101287021

Newbie level 6
Joined
Jul 9, 2014
Messages
14
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,382
IN RANDOM READ

THE I2C FRAME WHEN MICROCONTROLLER SEND NOACK THEN STOP THE FRAME

IN BETWEEN NOACK AND STOP FRAME A SINGLE BIT IS READ .SO THAT ALWAYS READ EVEN NUMBER

WHAT CAN I DO SO THAT AFTER NOACK FRAME IS STOP ? :bang:
 

Hello!

You might consider to stop yelling, that would be a good first step.
Then, what kind of EEPROM?
Then you should also consider building understandable sentences.
For example, using punctuation is a plus.
So what's the problem?

THE I2C FRAME

Let's assume that this is grammatically a subject

WHEN MICROCONTROLLER SEND NOACK THEN STOP THE FRAME
IN BETWEEN NOACK AND STOP FRAME

Can I consider this as a condition complement? (I'm talking of grammar here).

A SINGLE BIT IS READ .

What is this? What is the relation with "the i2c frame" above?

SO THAT ALWAYS READ EVEN NUMBER

Who reads an even number, and from where?

WHAT CAN I DO SO THAT AFTER NOACK FRAME IS STOP ?

The best thing you can do is to explain it in plain english, with points, columns, commas, etc so that
it becomes understandable. And a drawing might help. Or a scope screen copy...

Dora.
 

Hi,

1. at89s52 micro-controller read value [random read] from 24c16 eeprom.

2. Microcontroller is done write [byte write] operation

3. Microcontroller read always even number value .

4. Example - eeprom store 31 value in 00 memory location .when microcontroller read value and display in 2*16 lcd it display garbage .

5. But if it is store 30h in same location [00] then it display 0.

6. Why it is not display odd number ?
 

Hello!

It sounds like you have trouble in english. Let's try to rephrase first.

1. You are using an at89s52 and you plan to random read from 24c16 EEPROM.

2. Your microcontroller code is done? You mean it's finished and it works in byte write?
-> How do you know that your write function works? I mean: if you can't read
back, it may mean that the write function failed.

3. You mean that even if the EEPROM contains an odd value, your microcontroller reads
an even value?
-> How do you know that an odd value has been successfully written to the EEPROM?

4. So you have a microcontroller and a display.
-> Are you sure that the display works right? What happens if you try to write 31 to your LCD?
Does it work? Does it display 31 or grabage?
-> When you use the debugger, you write 31 to address 00. What happens when you read
from address 00? I mean: before writing to the LCD. Can you read anything? Is there some
correlation with what is written? For example you write 31 and you read 30?

5. Let's try to solve one problem at a time. Your EEPROM software does not work, so don't
display now. Try to make it work first. Use the debugger, try to write 0x30 and to read it back.

6. Try to write a piece of code that only writes and reads the EEPROM (without LCD).
Post it, and it will be easier to help you. As for your LCD code, try to do the same. LCD only code.
Comment out the I2C functions until it works, and then put everything together.

Dora.
 
Hello sir!

According your second point i am using led indication in every step.

in write operation when accumulator value move to carry at that time i am using led indication so that i know which value in store in which location.

Code:
example-    RLC    A                    ;accumulator value move to carry from right to left

in that time if carry = 1     then led glow
                     carry = 0     then same led off 
in this way i know 31h store in 00 eeprom memory location.

[COLOR="silver"][SIZE=1]- - - Updated - - -[/SIZE][/COLOR]

Hello sir,

sir this is my byte write code
			
;***  FOR 7 BIT ADDRESS I2C FRAME IS 		= START / 7 BIT ADDRESS / R/W / ACK / DATA / ACK /DATA / ACK / STOP
;***  FOR R/W = 0  IT SHOULD BE WRITE CONDITION , IF IT IS = 1 THEN IT IS READ CONDITION
;***  FOR START / STOP CLK SIGNAL CONDITION = HIGH
;***  FOR START DATA SIGNAL CONDITION       = HIGH TO LOW
;***  FOR STOP DATA SIGNAL  CONDITION       = LOW TO HIGH
;***  FOR CLK = P3.6  
;***  FOR DAT = P3.7 
;***  FOR LED = P0.4
								
				SCL				BIT   				P3.6
				SDA				BIT					P3.7
				LED				BIT					P0.4
								ORG					00H
	;							CLR					LED
								ACALL				DELAY
								SETB				SCL						;CLK SIGNAL IS HIGH
								NOP
								SETB				SDA						;DATA SIGNAL IS HIGH TO LOW FOR STARTING CONDITION
								NOP
								CLR					SDA						;DATA SIGNAL IS LOW
							    CLR					SCL
								
						;		ACALL				DELAY					; OFF
						;		ACALL				DELAY
						;		ACALL				DELAY	
						;		CPL					LED
								
								

;*** 7 BIT ADDRESS SEND IN SDA  
;*** AFTER EVERY BIT SEND DATA LINE HIGH TO LOW AND CLK HIGH

								MOV					B,#8					; B REGISTER CONTAIN VALUE 8
								MOV					A,#0A0H					; ACC STORE DEVICE ADDRESS [EEPROM]
		LOOP:					RLC					A						; ACC VALUE MOVE RIGHT TO LEFT IN CARRY
								MOV					SDA,C					; CARRY VALUE TRANSFER TO DEVICE THROUGH DATA LINE 
								SETB				SCL						; HIGH CLK SIGNAL
								NOP														; NO OPERATION
								NOP
								CLR					SCL						; LOW CLK SIGNAL
								NOP											; NO OPERATION
								DJNZ				B,LOOP					; DECREMENT B REGISTER AND JUMP LOOP LEVEL IF B=0 MOVE NEXT INSTRUCTION
								CLR					C						; CLEAR CARRY
							;	SETB				SDA
								NOP
								SETB				SCL						; HIGH CLK
								NOP											
		LOOP1:					JB					SDA,LOOP1				; WHEN SDA = 0 THEN MOVE NEXT INSTRUCTION OTHERWISE JUMP LOOP1	
								CLR					SCL						; CLEAR CLK
						;		ACALL				DELAY
						;		ACALL				DELAY
						;		ACALL				DELAY		
						;		CPL					LED						; ON
								
;*** STORE OFFSET ADDRESS IN EEPROM
		
								MOV					B,#8					; R1 REGISTER CONTAIN THE VALUE 8
								MOV					A,#00H			; 01H MEMORY LOCATION [EEPROM] DATA START TO STORE ACC=30H
		LOOP2:					RLC					A						; ACCUMULATOR VALUE MOVE CARRY FROM RIGHT TO LEFT 
								MOV					SDA,C					; CARRY VALUE MOVE TO DATA LINE
								SETB				SCL						; HIGH CLK SIGNAL
								NOP											; NOOPERATION OCCURE
								NOP
								CLR					SCL						; LOW CLK SIGNAL
								NOP							
								DJNZ				B, LOOP2				; DECREMENT R1 VALUE JUMP LOOP2 STIL R1=0 
								CLR					C						; CLEAR CARRY
							;	SETB				SDA
								NOP
								SETB				SCL						; HIGH CLK SIGNAL
		LOOP3:					JB					SDA, LOOP3				; WAIT WHEN SDA=0 THEN MOVE NEXT INSTRUCTION	
								CLR					SCL						; CLEAR CLK SIGNAL
						;		ACALL				DELAY
						;		ACALL				DELAY
						;		ACALL				DELAY
						;		CPL					LED	
						; OFF

;*** STORE DATA IN EEPROM                                                                                               
								CLR					A						; ACC = 0
								MOV					B,#8					; R1 REGISTER CONTAIN THE VALUE 8	
								MOV					A,#31H					; ACC VALUE STORE IN EEPROM IN 30H MEMORY LOCATION
		LOOP4:					RLC					A						; ACCUMULATOR VALUE MOVE CARRY FROM RIGHT TO LEFT
								MOV					SDA,C					; CARRY VALUE MOVE TO DATA LINE	
								SETB				SCL						; HIGH CLK SIGNAL
								NOP											; NO OPERATION
								NOP
								CLR					SCL						; LOW CLK SIGNAL
								NOP
								DJNZ				B,LOOP4				; DECREMENT R1 VALUE JUMP LOOP4 STIL R1=0
								CLR					C						; CARRY = 0
							;	SETB				SDA
								NOP
								SETB				SCL						; HIGH CLK SIGNAL
								NOP
		LOOP5:					JB					SDA, LOOP5				; WAIT WHEN SDA=0 THEN MOVE NEXT INSTRUCTION
								NOP
								CLR					SCL						; LOW CLK SIGNAL	
								CLR					LED
						;		ACALL				DELAY
						;		ACALL				DELAY
						;		ACALL				DELAY
						;		CPL					LED						; ON
								
;*** STOP I2C BUS
								
								SETB				SCL						; HIGH CLK SIGNAL
								NOP			
								;CLR					SDA						; LOW DATA LINE
								;NOP	
								SETB				SDA						; LOW DATA LINE
								NOP
								CLR					SCL
								
						;		ACALL				DELAY
						;		ACALL				DELAY
						;		ACALL				DELAY
						;		CPL					LED						; OFF
								
								SJMP				$						
								
								
								
;*** FOR READ OPERATION								
DELAY:		mov		r6,#150
VL3:		mov		r2,#143
VL2:		mov		r3,#20
VL1:		djnz	r3,VL1
			djnz	r2,VL2
			djnz	r6,VL3
			ret				
																
				END
 
Last edited by a moderator:

sir,

this my random read code

here i am not display read value but give led indication.


Code ASM - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
SCL    BIT      P3.6
  SDA    BIT      P3.7
  RS    BIT      P0.1
  EN    BIT      P0.0
  LED    BIT      P0.4
      ORG      00H
      MOV      R0,#30H
     ; ACALL     LCD
      ACALL     DELAY
      ACALL     DELAY
     ; CPL      LED
      
      ACALL     START
      
      ACALL     DEVICE_ADDRESS
       
      ACALL     ACK
      
      ACALL     WORD_ADDRESS
      
      ACALL     ACK
      
      ACALL     REPEAT_START
      
      ACALL     DEVICE_ADDRESS1
      
      ACALL     ACK
      
      ACALL     VALUE
     
      
      ACALL     NOACK
 
         
      ACALL     STOP 
        
      ACALL     EVE
 
LU2:     SJMP     $
      
;*** I2C START PROGRAM
      
START:     SETB     SCL
    ;  NOP
      SETB     SDA
    ;  NOP
      CLR      SDA
    ;  NOP
      CLR      SCL
 
    RET  
    
;*** I2C DEVICE ADDRESS PROGRAM
 
DEVICE_ADDRESS:   CLR      A
      MOV      R3,#8
      MOV      A,#0A0H
LOOP7:     
      CLR      SCL
      NOP
      RLC      A
      MOV      SDA,C
      SETB     SCL
      NOP
      NOP
      DJNZ     R3,LOOP7
      CLR      SCL
      CLR      C
    RET 
 
;*** I2C ACKNOWLEDGE SLAVE TO MASTER
 
ACK:     SETB     SCL
      NOP
      NOP
      NOP
LOOP8:     JB      SDA,LOOP8
      NOP
      CLR      SCL
      NOP
    RET  
    
;*** I2C WORD ADDRESS    
 
WORD_ADDRESS:   MOV      R1,#8     ; R1 REGISTER CONTAIN THE VALUE 8
      MOV      A,#00H   ; 30H MEMORY LOCATION [EEPROM] DATA START TO STORE ACC=30H
LOP8:     RLC      A      ; ACCUMULATOR VALUE MOVE CARRY FROM RIGHT TO LEFT 
      MOV      SDA,C     ; CARRY VALUE MOVE TO DATA LINE
      SETB     SCL      ; HIGH CLK SIGNAL
      NOP
      NOP
      CLR      SCL      ; LOW CLK SIGNAL
      NOP       
      DJNZ     R1, LOP8    ; DECREMENT R1 VALUE JUMP LOOP2 STIL R1=0 
      CLR      C         ; CLEAR CARRY
    RET
 
;*** I2C REPETED START
 
REPEAT_START:   SETB     SDA
      NOP
      NOP
      SETB     SCL
      NOP
      NOP
      CLR      SDA
      NOP
      CLR      SCL
      NOP
    RET  
    
      
;*** I2C READ DEVICE ADDRESS
 
DEVICE_ADDRESS1:  CLR      A
      MOV      R2,#8
      MOV      A,#0A1H
      NOP
LOP7:     CLR      SCL
      NOP
      RLC      A
      MOV      SDA,C
      SETB     SCL
      NOP
      NOP
      NOP
      DJNZ     R2,LOP7
      CLR      SCL
      NOP
      CLR      C
    RET 
    
;*** I2C VALUE
 
VALUE:       CLR     SCL
        MOV     R1,#8
LOOP14:       SETB    SCL
         NOP
        NOP
        MOV     C,SDA
        NOP
        NOP
        CLR     SCL
        NOP
        NOP
        RLC     A
        NOP
        DJNZ    R1,LOOP14
        NOP
 
        CLR     C
 
     RET
     
;*** I2C ACK
 
ACK1:       CLR     SDA
        SETB    SCL
 ;       NOP
 ;       CLR     SDA
 ;       NOP
     RET
;*** I2C NO ACK
 
NOACK:       SETB    SDA
        NOP
        SETB    SCL
        NOP
        NOP
        NOP
        NOP
        CLR     SCL
        
     RET   
     
;*** I2C STOP
 
STOP:       CLR     SDA
        NOP
        NOP
        SETB    SCL
        NOP
        NOP
        NOP
        NOP
        SETB    SDA
        
     RET
   
 
;*** I2C STOP ONE
 
STOP1:       CLR     SCL
        NOP
        MOV     C,SDA
        NOP
        SETB    SCL
        NOP
        SETB    SDA
        NOP
        CLR     SCL
        MOV     ACC.0,C
     RET   
        
;*** I2C SHOW
 
ODD:       MOV     ACC.0,C
        MOV     R0,#30H
        MOV     A,@R0
        MOV     P0,A
        NOP
     RET
EVE:       ;MOV     R0,#30H
        ;MOV     A,@R0
        MOV     P0,A
        NOP
     RET   
 
STORE:       MOV     @R0,A
        MOV     B,#2H
        DIV     AB
        MOV     R1,B
        CJNE    R1,#00H,DE
        MOV     R3,#4
        CLR     SCL
     RET
MH:        ACALL    SINGLE
DE:     RET
 
;*** I2C FOR SINGLE BIT
 
SINGLE:       CLR     SCL
        MOV     C,SDA
       ; SETB    SCL
     RET   
 
 
;*** LCD INNITIALIZE PROGRAM
 
LCD:     MOV      DPTR,#LU
LOP1:     MOVC     A,@A+DPTR
      JZ      LOP
      ACALL     CMD
      ACALL     DELAY1
      INC      DPTR
      CLR      A
      SJMP     LOP1
LOP:   RET
 
;*** COMMAND LINE PROGRAM FOR LCD
      
CMD:     MOV      P2,A
      CLR      RS
      SETB     EN
      ACALL     DELAY1
      CLR      EN
    RET
 
;*** DATA LINE FOR LCD PROGRAM
 
DAT:     MOV      P2,A
      SETB     EN
      SETB     RS
      ACALL     DELAY1
      CLR      EN
    RET
    
 
;*** DELAY1 FOR LCD
  
DELAY1:     MOV      R6,#143
OOP2:     MOV      R7,#50
OOP3:     DJNZ     R7,OOP3
      DJNZ     R6,OOP2
    RET  
 
;*** DELAY PROGRAM FOR MAIN PROGRAM
  
DELAY:     MOV      R5,#150
OOP4:     MOV      R6,#143
OOP5:     MOV      R7,#20
OOP6:     DJNZ     R7,OOP6
      DJNZ     R6,OOP5
      DJNZ     R5,OOP4
    RET  
   
LU:     DB      38H,01H,06H,0EH,80H,0
END

 

Hello sir,

byte write and random read both are done . problem is in byte write acknowledge but now it is rectify.

- - - Updated - - -

sir,
1. In sequential random read when data out is done . A acknowledge send from master to slave in this acknowledge sda is low and what is the clock signal ?
2. clock signal is high to low or low to high .
 
Last edited:

Hello!

I don't use assembler, but it looks like you are bit-banging I2C (you are setting s SDA / SCK "by hand")
Why? You are using a processor with no I2C? An advice: if you are using I2C in your project, choose
an I2C compatible device.

Dora.
 

HI,
sir i need two bit for clock signal and serial data line for communicate with eeprom (24c16).

so it is possible in 89s52.
 

Yes, I2C interface can be made by two port pins with 89S52.

That's basically correct in the posted code. If something's wrong, it's about code details.
 

hello!
sir,
sequential random read is not done .
but sir i am doing everything according to the i2c bus frame like page write in 3 memory location then sequential random read but still it is not working.

when i am read the value only it is show in (2 * 16 lcd )the first location value and other two are garbage.
 

Hello!

It's been years that I worked with assembler, But I would like to share some old routines so you can check them,

Please take in account that this routines works only with those 24C01 to 24C16 (those that works with 1 byte address)

Code:
FADDR		EQU	0a0h		; fixed address for AT24Cxx EEPROMs
PADDR		EQU	0		; programmable address (0..7)
PSIZE		EQU	32		; bytes per page for AT24C64
buffer	EQU	30h		; storage for read/write data

; Register definitions.
index		EQU	r0		; buffer pointer
kount		EQU	r1		; byte count register
zdata		EQU	r1		; data register
addr		EQU	r2		; address register

; Microcontroller connections to AT24Cxx serial bus lines.
SCL		BIT	p1.2		; serial clock
SDA		BIT	p1.3		; serial data

write_block:
		call	start
		jc	x38		; abort if bus not available
		rl	a		; programmable address to bits 3:1
		orl	a, #FADDR	; add fixed address
		clr	acc.0		; specify write operation
		call	shout		; send device address
		jc	x37		; abort if no acknowledge
		mov	a, addr	; send byte of address
		call	shout		;
		jc	x37		; abort if no acknowledge
		mov	index, #buffer	; point to buffer
	x36:	mov	a, @index	; get data
		call	shout		; send data
		jc	x37		; abort if no acknowledge
		inc	index		; advance buffer pointer
		djnz	kount, x36	; next byte
		clr	c		; clear error flag
	x37:	call	stop
	x38:	ret

read_block:
		call	start
		jc	x35		; abort if bus not available
		rl	a		; programmable address to bits 3:1
		orl	a, #FADDR	; add fixed address
		mov	index, a	; save copy of device address
		clr	acc.0		; specify write operation
		call	shout		; send device address
		jc	x34		; abort if no acknowledge
		mov	a, addr	; send byte of address
		call	shout		;
		jc	x34		; abort if no acknowledge
		; Send read command and receive data.
		call	start		; second start for read
		jc	x34		; abort if bus not available
		mov	a, index	; get device address
		setb	acc.0		; specify read operation
		call	shout		; send device address
		jc	x34		; abort if no acknowledge
		mov	index, #buffer	; point to buffer
	x31:	call	shin		; receive data byte
		mov	@index, a	; save data
		cjne	kount, #1, x32	; jump if not last byte
		call	NAK		; do not acknowledge last byte
		jmp	x33		; done
	x32:	call	ACK		; acknowledge byte
		inc	index		; advance buffer pointer
		djnz	kount, x31	; next byte
	x33:	clr	c		; clear error flag
	x34:	call	stop
	x35:	ret


write_byte:
		call	start
		jc	x49		; abort if bus not available
		rl	a		; programmable address to bits 3:1
		orl	a, #FADDR	; add fixed address
		clr	acc.0		; specify write operation
		call	shout		; send device address
		jc	x48		; abort if no acknowledge
		mov	a, addr	; send byte of address
		call	shout		;
		jc	x48		; abort if no acknowledge
		mov	a, zdata	; get data
		call	shout		; send data
		jc	x48		; abort if no acknowledge
		clr	c		; clear error flag
	x48:	call	stop
	x49:	ret


read_current:
		call	start
		jc	x45		; abort if bus not available
		rl	a		; programmable address to bits 3:1
		orl	a, #FADDR	; add fixed address
		setb	acc.0		; specify read operation
		call	shout		; send device address
		jc	x44		; abort if no acknowledge
		call	shin		; receive data byte
		call	NAK		; do not acknowledge byte
		clr	c		; clear error flag
	x44:	call	stop
	x45:	ret


read_random:
		push	b
		mov	b, a		; save copy of programmable address
		; Send dummy write command to set internal address.
		call	start
		jc	x47		; abort if bus not available
		rl	a		; programmable address to bits 3:1
		orl	a, #FADDR	; add fixed address
		clr	acc.0		; specify write operation
		call	shout		; send device address
		jc	x46		; abort if no acknowledge
		mov	a, addr	; send byte of address
		call	shout		;
		jc	x46		; abort if no acknowledge
		; Call Current Address Read function.
		mov	a, b		; get programmable address
		call	read_current
		jmp	x47		; exit
	x46:	call	stop
	x47:	pop	b
		ret


start:
		setb	SDA
		setb	SCL
		jnb	SDA, x40	; jump if not high
		jnb	SCL, x40	; jump if not high
		nop			; enforce setup delay and cycle delay
		clr	SDA
		nop			; enforce hold delay
		nop			;
		nop			;
		nop			;
		nop			;
		clr	SCL
		clr	c		; clear error flag
		jmp	x41
	x40:	setb	c		; set error flag
	x41:	ret
stop:
		clr	SDA
		nop			; enforce SCL low and data setup
		nop
		setb	SCL
		nop			; enforce setup delay
		nop			;
		nop			;
		nop			;
		nop			;
		setb	SDA
		ret
shout:

		push	b
		mov	b, #8		; bit counter
	x42:	rlc	a		; move bit into CY
		mov	SDA, c		; output bit
		nop			; enforce SCL low and data setup
		setb	SCL		; raise clock
		nop			; enforce SCL high
		nop			;
		nop			;
		nop			;
		clr	SCL		; drop clock
		djnz	b, x42		; next bit
		setb	SDA		; release SDA for ACK
		nop			; enforce SCL low and tAA
		nop			;
		setb	SCL		; raise ACK clock
		nop			; enforce SCL high
		nop			;
		nop			;
		nop			;
		mov	c, SDA		; get ACK bit
		clr	SCL		; drop ACK clock
		pop	b
		ret


shin:
		setb	SDA		; make SDA an input
		push	b
		mov	b, #8		; bit count
	x43:	nop			; enforce SCL low and data setup
		nop			;
		nop			;
		setb	SCL		; raise clock
		nop			; enforce SCL high
		nop			;
		mov	c, SDA		; input bit
		rlc	a		; move bit into byte
		clr	SCL		; drop clock
		djnz	b, x43		; next bit
		pop	b
		ret

ACK:
		clr	SDA		; ACK bit
		nop			; enforce SCL low and data setup
		nop			;
		setb	SCL		; raise clock
		nop			; enforce SCL high
		nop			;
		nop			;
		nop			;
		clr	SCL		; drop clock
		ret


NAK:
		setb	SDA		; NAK bit
		nop			; enforce SCL low and data setup
		nop			;
		setb	SCL		; raise clock
		nop			; enforce SCL high
		nop			;
		nop			;
		nop			;
		clr	SCL		; drop clock
		ret

Sorry I can't help you with your own code, but something I didn't catch in your code, is that After a writing, you need to wait AT LEAST 10ms before accessing the eeprom, if access intermediately after a write, it will always answer as NAK until it's ready (10ms after) and then it'll answer a correct ACK...
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top