| ??? 06/08/11 14:57 Read: times  | 
#182539 - I doubt it very much Responding to: ???'s previous message  | 
See if this code is of any help!
 I doubt it very much the OP said: I am successfully interfaced 89C52 with 24C02, but my question is How to set communication speed ie 100 kbps. I calculate below and have been VERY much lowballing the time for a C instruction. Erik #define I2C_DELAY 0x0F	                    // For delay i2c bus 
void I2C_delay(void)
{
	unsigned char i;
	for(i=0; i<I2C_DELAY; i++);
}
void I2C_clock(void)                                      60
{
	I2C_delay();
	set_scl;		// Start clock             2 
	I2C_delay();                                      60
	clr_scl;		// Clear SCL               2
}
                                                          =====
                                                          124
// this is totally unpredictable being a C delay, but I'll set it to 60 cycles
	for(i=0;i<8;i++)		//sending 8 bits of data                  say 3
	{
	 data_bit = dat & 0x80;		// Filter MSB bit keep to data_bit        say 3
	 sda = data_bit;		// Send data_bit to SDA                   say 3
	I2C_clock();      		// Call for send data to i2c bus            124  
	dat = dat<<1;                                                              say 7
	}
                                                                                  ==========
                                                                                   140
with the old steam driven uC the OP uses running at 24MHz the bit rate would be 2M/140 ~ 14kHz  | 
| Topic | Author | Date | 
| Help me ? 89C52 interfacing with EEPROM 24C02 | 01/01/70 00:00 | |
| Do *not* use 'for' loops for delays! | 01/01/70 00:00 | |
| 100k is the upper limit | 01/01/70 00:00 | |
| HLL delay loops - just don't do it! | 01/01/70 00:00 | |
| that may be difficult | 01/01/70 00:00 | |
| but there is a way | 01/01/70 00:00 | |
| See if this code is of any help! | 01/01/70 00:00 | |
| I doubt it very much | 01/01/70 00:00 | |
| No, it isn't | 01/01/70 00:00 | |
| doubts 1,2,3 | 01/01/70 00:00 | |
| code for 24c02 wih 89c52 | 01/01/70 00:00 | |
| Do *not* use 'for' loops for delays! | 01/01/70 00:00 | |
      code?        | 01/01/70 00:00 | 



