| ??? 11/27/09 11:05 Read: times |
#171226 - single byte read write working Responding to: ???'s previous message |
thanks to David and of course Murray and all other members,
I now can write and then read data from the 24C256 one byte at a time. Now i am trying Page Write and sequential read. also will try to write data then power off and then read to make sure the data is intact. Then i will use it in the main project. I presently have this code that i have below. Will get back with the rest of the results by Sunday.
#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;//this is to store and send the data that is read
char DATA_ = 0x00;//this is to store the present value of data
char ADD_ = 0x10;//this is to store the present value of address
initialize_serial();//intializes the serial port
while(1)
{
/********WRITE TO ADDRESS********/
i2c_transmit_start();
i2c_transmit_byte(0xA0);
i2c_transmit_byte(0x10);//higher byte of address
i2c_transmit_byte(ADD_);//lower byte of address
i2c_transmit_byte(DATA_);
i2c_transmit_stop();
msec_wait(200);//wait after write for 200 mili-seconds
/********READ FROM ADDRESS*******/
i2c_transmit_start();
i2c_transmit_byte(0xA0);
i2c_transmit_byte(0x10);//higher byte of address
i2c_transmit_byte(ADD_);//lower byte of address
i2c_transmit_restart();
i2c_transmit_byte(0xA1);
BYTE_GET = i2c_receive_byte(I2C_NAK);
i2c_transmit_stop();
SBUF = BYTE_GET;//sends the character read serially to my PC
DATA_++;//increments the data that is to be written next
/******************************************/
ADD_++;//increments the lower byte of address
}
}
|
| 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 |



