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.

[SOLVED] pic 16F877 interface with 24c02c problem.....

Status
Not open for further replies.

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;

} }



 

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;

} }


 

Delay_ms(10);

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.
 

sir but microC have not these functions. sir this code is used in which compiler
 

then change it according to your compiler!!
the above code is of mikroc pro for pic compiler.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top