Sep 21, 2010 #1 sudheepsrc Junior Member level 3 Joined Aug 8, 2010 Messages 28 Helped 2 Reputation 4 Reaction score 2 Trophy points 1,283 Location kerala Activity points 1,474 sir, the code is not working with this HW in proteus and can't see the data 0x10h why??? void main() { for(; { TRISB=0; // set PORTB to be input I2C_Init(100000); I2C_Start(); I2C_Wr(0xA2); I2C_Wr(0x04); I2C_Wr(0x10); I2C_Stop(); Delay_ms(10); I2C_Start(); // Issue I2C start signal I2C_Wr(0xA2); // Send byte via I2C (device address + W) I2C_Wr(0x04); // Send byte (data address) I2C_Repeated_Start(); // Issue I2C signal repeated start I2C_Wr(0xA3); // Send byte (device address + R) PORTB = I2C_Rd(0); // Read the data (NO acknowledge) I2C_Stop(); delay_ms(100); PORTB=0; } }
sir, the code is not working with this HW in proteus and can't see the data 0x10h why??? void main() { for(; { TRISB=0; // set PORTB to be input I2C_Init(100000); I2C_Start(); I2C_Wr(0xA2); I2C_Wr(0x04); I2C_Wr(0x10); I2C_Stop(); Delay_ms(10); I2C_Start(); // Issue I2C start signal I2C_Wr(0xA2); // Send byte via I2C (device address + W) I2C_Wr(0x04); // Send byte (data address) I2C_Repeated_Start(); // Issue I2C signal repeated start I2C_Wr(0xA3); // Send byte (device address + R) PORTB = I2C_Rd(0); // Read the data (NO acknowledge) I2C_Stop(); delay_ms(100); PORTB=0; } }
Sep 21, 2010 #2 malik_zohaib Full Member level 5 Joined Sep 1, 2010 Messages 261 Helped 36 Reputation 72 Reaction score 35 Trophy points 1,308 Location Pakistan Activity points 2,707 code: void main() { for(; { TRISB=0; // set PORTB to be output I2C1_Init(100000); I2C1_Start(); I2C1_Wr(0xA2); I2C1_Wr(0x04); I2C1_Wr(0x10); I2C1_Stop(); Delay_ms(10); I2C1_Start(); // Issue I2C start signal I2C1_Wr(0xA2); // Send byte via I2C (device address + W) I2C1_Wr(0x04); // Send byte (data address) I2C1_Repeated_Start(); // Issue I2C signal repeated start I2C1_Wr(0xA3); // Send byte (device address + R) PORTB = I2C1_Rd(0); // Read the data (NO acknowledge) I2C1_Stop(); delay_ms(100); PORTB=0; } }
code: void main() { for(; { TRISB=0; // set PORTB to be output I2C1_Init(100000); I2C1_Start(); I2C1_Wr(0xA2); I2C1_Wr(0x04); I2C1_Wr(0x10); I2C1_Stop(); Delay_ms(10); I2C1_Start(); // Issue I2C start signal I2C1_Wr(0xA2); // Send byte via I2C (device address + W) I2C1_Wr(0x04); // Send byte (data address) I2C1_Repeated_Start(); // Issue I2C signal repeated start I2C1_Wr(0xA3); // Send byte (device address + R) PORTB = I2C1_Rd(0); // Read the data (NO acknowledge) I2C1_Stop(); delay_ms(100); PORTB=0; } }
Sep 21, 2010 #3 M millwood Advanced Member level 3 Joined Jul 2, 2009 Messages 733 Helped 80 Reputation 164 Reaction score 35 Trophy points 1,308 Activity points 5,088 Delay_ms(10); Click to expand... this is not a big deal if you are writing small amount of data to the eeprom. however, if you are writing large amount of data to eeprom, the delay can be significant. in that case, you may wish to check out the datasheet for acknowledge polling.
Delay_ms(10); Click to expand... this is not a big deal if you are writing small amount of data to the eeprom. however, if you are writing large amount of data to eeprom, the delay can be significant. in that case, you may wish to check out the datasheet for acknowledge polling.
Sep 22, 2010 #4 sudheepsrc Junior Member level 3 Joined Aug 8, 2010 Messages 28 Helped 2 Reputation 4 Reaction score 2 Trophy points 1,283 Location kerala Activity points 1,474 sir but microC have not these functions. sir this code is used in which compiler
Sep 22, 2010 #5 malik_zohaib Full Member level 5 Joined Sep 1, 2010 Messages 261 Helped 36 Reputation 72 Reaction score 35 Trophy points 1,308 Location Pakistan Activity points 2,707 then change it according to your compiler!! the above code is of mikroc pro for pic compiler.