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.

I2C Write Time

Status
Not open for further replies.

Suraj143

Active Member
Can somebody tell me how much time does it take to write a byte?I use I2C module.

Standard what frequency do I need to use 100Khz or 400Khz?
 
Last edited:
It depends on what you are writing to. For example, a 24xx1025 can write a 128 byte page in 6mS (3mS to transmit + 3mS to write).

Mike.
 
Hi Mike I use 24C08 can you tell I just need to write a "Value" to the EEPROM.

Including Start--Control Address--E2 Pointer---Data---Stop.How much time will it takes.(I'm not writing a block i just writing a Byte)

I have attached the data sheet.
 

Attachments

  • 24C08B.pdf
    79.7 KB · Views: 212
Last edited:
Transmit time will be around 3mS as it is a 100k device. The write time will be another 10mS. So, 13mS per byte.

Mike.
 
Oh god that is too much time.I thought I2C is really speed but its too slow.But in all over the world it is using I don't know why they using if it too slow.

PIC internal EEPROM is speeder than this that takes 4mS of time per byte.
 
I get a string of characters.I need to save UART receiving character to the 24C memory at each "RCIF".With that 13mS time I'll miss many incoming characters from UART.
 
Last edited:
Oh god that is too much time.I thought I2C is really speed but its too slow.But in all over the world it is using I don't know why they using if it too slow.

I2C is for a specific purpose, for interconnecting IC's on a large PCB - as such it's plenty fast enough for it's intended use.

However, in this case it's not a specific I2C limitation, it's just the writing speed of EEPROM - you should use block mode to make it faster.
 
Nigel can you give me an idea on how to do this.

I get a string of characters from a PC (over 200-300 characters).I want to save these characters for later use.How can I achieve this?

I have not decided the PIC yet what ever you all suggest I can use it :)
 
Nigel can you give me an idea on how to do this.

I get a string of characters from a PC (over 200-300 characters).I want to save these characters for later use.How can I achieve this?

I have not decided the PIC yet what ever you all suggest I can use it :)


The first thing you have to receive the ( 200-300 characters ) and sore them in a RAM buffer in your system then start writing them to the 24C08
 
Now here the problem comes.

Let say I'm receiving 300 characters & I have 200 free RAM .So I'll receive UART characters & save them in GP RAM.After receiving I start writing to 24C08 then it will take 13mS X 200 = 2600mS time,this will miss many characters in the balance 100 receiving characters.
 
Now here the problem comes.

Let say I'm receiving 300 characters & I have 200 free RAM .So I'll receive UART characters & save them in GP RAM.After receiving I start writing to 24C08 then it will take 13mS X 200 = 2600mS time,this will miss many characters in the balance 100 receiving characters.

Choose a PIC with more RAM - also use block writing mode so you can write them much faster.

For that matter, use handshaking on the link from the PC.
 
You can also crank up the speed to 1000kbps, at the expense of lower value pullup resistors. It's been a while, but 1kΩ pullups would probably be in the ballpark.
 
Ok guys thanks for your comments.

In block write mode i'm going to write 16 bytes at once.after the stop condition do i need to wait 10ms X 16 = 160ms ?

For the time being i have a single byte write routine.in that also i wait 10ms after stop condition.
 
I'm writing some data to the 24C08 & it will display on LED's.
The problem is everytime from the value 13 onwards the data is incorrect.
(I guess that there is some problem with lower 4 bits of pointer address)

The data is correct when I write them from location 0x00 instead of 0x04.

Code:
;================================================================
;write the data to the 24C08
;70h-7Fh contains data
;================================================================		

Write_24C08	movlw	b'00000100'		; Write from 0x04
		movwf	E2_Add_Low
		clrf	E2_Add_High
		movlw	70h
		movwf	FSR
		movlw	.16
		movwf	Byte_Count		; write 16 bytes at once
		call	I2C_Page_Write
		---
		---


I2C_Page_Write	call	I2C_Start
		rlf	E2_Add_High,W
		andlw	b'00001110'
		iorlw	b'10100000'		; Slave Address - WR
		call	I2C_Write
		movf	E2_Add_Low,W
		call	I2C_Write
		;			
Page_Write_Loop	movf	INDF,W
		call	I2C_Write
		incf	FSR,F
		decfsz	Byte_Count,F
		goto	Page_Write_Loop
		call	I2C_Stop
		call	Delay10
		return

;==============================================
;Show the written data on the display
;==============================================

Show_Setup	movlw	.16
		movwf	Byte_Count
		movlw	b'00000100'
		movwf	E2_Add_Low
		;
Show_Loop	call	I2C_Byte_Read
		movwf	Number
		call	Display_Number		; show on LED's
		call	Delay255
		call	Delay255
		call	Delay255
		call	Delay255
		incf	E2_Add_Low,F		; increment E2 Pointer
		decfsz	Byte_Count,F
		goto	Show_Loop
		goto	Show_Setup


I2C_Byte_Read	call	I2C_Start
		movlw	b'10100000'		; Slave Address - WR
		call	I2C_Write
		movf	E2_Add_Low,W
		call	I2C_Write
		call	I2C_Restart
		movlw	b'10100001'		; Slave Address - Read
		call	I2C_Write
		call	I2C_Read
		movf	SSPBUF,W
		call	NACK_Slave
		call	I2C_Stop
		return
 
A page write always starts and ends on a page boundary and so the bottom 4 bits of the address should be zero.

Mike.
 
You can write to location 4 but if you write 16 bytes then the last bytes will go in location 0 to 3. I.E. it wraps around in the 16 byte page.

Mike.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top