Wire.read() always returns 255
With Wire library example works correctly
`#include
include
SoftWire Wire(SDA, SCL);
define disk1 0x50 //Address of 24C32 eeprom chip
void setup(void)
{
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for native USB port only
}
Serial.println("Wire");
Wire.begin();
You must allocate TX and RX buffers and pass them into SoftWire by calling the setTxBuffer() and setRxBuffer() functions. This is shown in the newly-added ReadDS1307 example.
Wire.read() always returns 255 With Wire library example works correctly
`#include
include
SoftWire Wire(SDA, SCL);
define disk1 0x50 //Address of 24C32 eeprom chip
void setup(void) { Serial.begin(9600); while (!Serial) { ; // wait for serial port to connect. Needed for native USB port only } Serial.println("Wire"); Wire.begin();
unsigned int address = 0; Serial.println("writeEEPROM"); writeEEPROM(disk1, address, 123); Serial.println("readEEPROM"); Serial.println(readEEPROM(disk1, address), DEC); Serial.println("end"); }
void loop(){}
void writeEEPROM(int deviceaddress, unsigned int eeaddress, byte data ) { Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); // MSB Wire.write((int)(eeaddress & 0xFF)); // LSB Wire.write(data); Wire.endTransmission();
delay(5); }
byte readEEPROM(int deviceaddress, unsigned int eeaddress ) { byte rdata = 0xFF;
Wire.beginTransmission(deviceaddress); Wire.write((int)(eeaddress >> 8)); // MSB Wire.write((int)(eeaddress & 0xFF)); // LSB Wire.endTransmission();
Wire.requestFrom(deviceaddress,1);
if (Wire.available()) rdata = Wire.read();
return rdata; }`