| ??? 11/25/09 16:43 Read: times |
#171164 - Writing to specific address Responding to: ???'s previous message |
Hello members,
I need to ask something about the 24C256. According to the datasheet i have to give a 2 byte address. now using the i2c format, can i write two bytes one by one. My main program looks like this. Address to which data is to be written - 0xAAAAh : 1010101010101010
#include<I2C.h>
#include<generic.h>
void main()
{
char BYTE_GET = 0x00,DATA_ = 0x11;
GREEN_LED = 0;//Just An indication for my hardware
YELLOW_LED = 0;//Just An indication for my hardware
sec_wait(1);
GREEN_LED = 1;//Just An indication for my hardware
YELLOW_LED = 1;//Just An indication for my hardware
sec_wait(1);
/********WRITE TO ADDRESS********/
i2c_transmit_start();
i2c_transmit_byte(0xA0);
i2c_transmit_byte(0xAA);//First word address
i2c_transmit_byte(0xAA);//Second word address
i2c_transmit_byte(DATA_);
i2c_transmit_stop();
/********READ FROM ADDRESS*******/
i2c_transmit_start();
i2c_transmit_byte(0xA0);
i2c_transmit_byte(0xAA);//First word address
i2c_transmit_byte(0xAA);//Second word address
i2c_transmit_start();
i2c_transmit_byte(0xA1);
BYTE_GET = i2c_receive_byte(I2C_NAK);
i2c_transmit_stop();
if(BYTE_GET == DATA_)//here we compare the data that was written to that we received.
GREEN_LED = 0;//GREEN indication if they match
else
YELLOW_LED = 0;//YELLOW if they do not match
sec_wait(1);
GREEN_LED = 1;
YELLOW_LED = 1;
sec_wait(1);
DATA_ ++;//now i increment the data so that the next time this incremented character is written
}
|
| 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 |



