Hello all,
Not logged onto the forum for a long while, but I remember how helpful everyone is with PIC problems... I have another one which is a bit perplexing.
I'm writing a program that writes a single byte of data to an external EEPROM (ATMEL 24C128B) from a 16F876A micrcontroller using I2C. I've been using this document from Microchip as a guide and it's been pretty good up to now. I've not been copying the code exactly, but taking the general structure and implementing it myself to understand the concepts.
When I have written a byte to the EEPROM I immediately read it (there is an ACK loop in the code to test whether the EEPROM is busy) and then send the result back to Hyperterminal using code that I know definitely works and use alot in other projects.
The problem I'm having is that the value 0xFF is always returned. I'm not sure whether this is a read or write problem, as the datasheet for the EEPROM does not state what the default value of each memory location is and I suspect that I could be reading the default value. I've confirmed that the chip is wired up correctly by illuminating an LED once the whole program has completed (write EEPROM, read EEPROM, transmit data byte, light LED), as the program would get stuck in the loops that check for ACK signals.
The code of my program is attached and I hope it's legible. I appreciate any help as I've been through the code a few times now and I think I'm overlooking something obvious.
Thanks again,
Pete
Not logged onto the forum for a long while, but I remember how helpful everyone is with PIC problems... I have another one which is a bit perplexing.
I'm writing a program that writes a single byte of data to an external EEPROM (ATMEL 24C128B) from a 16F876A micrcontroller using I2C. I've been using this document from Microchip as a guide and it's been pretty good up to now. I've not been copying the code exactly, but taking the general structure and implementing it myself to understand the concepts.
When I have written a byte to the EEPROM I immediately read it (there is an ACK loop in the code to test whether the EEPROM is busy) and then send the result back to Hyperterminal using code that I know definitely works and use alot in other projects.
The problem I'm having is that the value 0xFF is always returned. I'm not sure whether this is a read or write problem, as the datasheet for the EEPROM does not state what the default value of each memory location is and I suspect that I could be reading the default value. I've confirmed that the chip is wired up correctly by illuminating an LED once the whole program has completed (write EEPROM, read EEPROM, transmit data byte, light LED), as the program would get stuck in the loops that check for ACK signals.
The code of my program is attached and I hope it's legible. I appreciate any help as I've been through the code a few times now and I think I'm overlooking something obvious.
Thanks again,
Pete