| ??? 11/26/09 13:29 Read: times |
#171195 - Incorrect reply Responding to: ???'s previous message |
Dear David and Murray,
I am presently getting a reply from the eeprom(or i think i am) but it is incorrect. I am writing a 0x11h and getting 0xFFh in reply. Another thing is that this write and read loop should be infinite but in my hardware i can write once and then read, after that the program stops. as David said i corrected the address. I made some additions to the program by sending A unique character after each command to my PC and the reply i get each time, just to check where does my program get stuck 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 FF//here should be 11 instead 11 13 ...then nothing after that cannot think of any particular reason for this !!
#include<I2C.h>
#include<generic.h>
#include<serial.h>
void serial_interrupt() interrupt 4
{
if(TI)
{
TI = 0;
}
if(RI)
{
RI = 0;
}
}
void main()
{
char BYTE_GET = 0x00,DATA_ = 0x11;
initialize_serial();
SBUF = 0x11;
usec_wait(200);
SBUF = 0x12;
usec_wait(200);
while(1)
{
/********WRITE TO ADDRESS********/
i2c_transmit_start();
SBUF = 0x13;
usec_wait(200);
i2c_transmit_byte(0xA0);
SBUF = 0x14;
usec_wait(200);
i2c_transmit_byte(0x11);
SBUF = 0x15;
usec_wait(200);
i2c_transmit_byte(0x11);
SBUF = 0x16;
usec_wait(200);
i2c_transmit_byte(DATA_);
SBUF = 0x17;
usec_wait(200);
i2c_transmit_stop();
SBUF = 0x18;
usec_wait(200);
msec_wait(200);//wait after write
/********READ FROM ADDRESS*******/
i2c_transmit_start();
SBUF = 0x19;
usec_wait(200);
i2c_transmit_byte(0xA0);
SBUF = 0x20;
usec_wait(200);
i2c_transmit_byte(0x11);
SBUF = 0x21;
usec_wait(200);
i2c_transmit_byte(0x11);
SBUF = 0x22;
usec_wait(200);
i2c_transmit_start();
SBUF = 0x23;
usec_wait(200);
i2c_transmit_byte(0xA1);
SBUF = 0x24;
usec_wait(200);
i2c_transmit_stop();
SBUF = 0x25;
usec_wait(200);
BYTE_GET = i2c_receive_byte(I2C_NAK);
sec_wait(1);
SBUF = BYTE_GET;
msec_wait(1);
SBUF = DATA_;
msec_wait(1);
DATA_ ++;
}
}
|
| Topic | Author | Date |
| AT24C256 | 01/01/70 00:00 | |
| help | 01/01/70 00:00 | |
| BitBang's Amost Always.... | 01/01/70 00:00 | |
| Why use void functions | 01/01/70 00:00 | |
| thanks | 01/01/70 00:00 | |
| Writing to specific address | 01/01/70 00:00 | |
| Send sensible address values. | 01/01/70 00:00 | |
| I2C_0.0.zip | 01/01/70 00:00 | |
| no luck, | 01/01/70 00:00 | |
| You have more pins to mis-wire. | 01/01/70 00:00 | |
| i2c used, What should be the address | 01/01/70 00:00 | |
| Read Murray's excellent Help Files | 01/01/70 00:00 | |
| Incorrect reply | 01/01/70 00:00 | |
| Please take some time to READ the Help | 01/01/70 00:00 | |
| single byte read write working | 01/01/70 00:00 | |
I2C_0.1.zip released! | 01/01/70 00:00 |



