Skip to main content
Commonmark migration
Source Link

I'm working on a project where I have to communicate to several devices over I2C using a Genuino 101. Now I'm trying to get data off the bus but wire.available() stays at 0, even though my trace clearly shows there's data being sent.

 i2c trace

with the following timings

enter image description here

timings

Because the wire is never available my readbuf will always be empty.

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

I'm using the following code to read from the I2C bus.

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
  ushort memstart = memory;
  bool available = true;;
  while (len > 0 && available) {
    available = false;
    ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;
    Wire.beginTransmission(static_cast<int>(device));
    //send i2c START command
    Wire.write(memory);
    //Write memory address
    Wire.endTransmission();
    //send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true);
    //Request blockSize bytes from the device
    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
      available = true;
      rdBuf[memory - memstart] = Wire.read();
      memory++;
      len--;
    }
  }
}

I'm not quite sure what I'm doing wrong, any help would be much appreciated.

#Edit:

Edit:

Below is an image of the current (minimal) setup. On the left there's the board with the ADC and multiplexer visible.

Arduino setup

The third set of wires goes to my protocol analyzer.

I'm working on a project where I have to communicate to several devices over I2C using a Genuino 101. Now I'm trying to get data off the bus but wire.available() stays at 0, even though my trace clearly shows there's data being sent.

 i2c trace

with the following timings

enter image description here

timings

Because the wire is never available my readbuf will always be empty.

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

I'm using the following code to read from the I2C bus.

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
  ushort memstart = memory;
  bool available = true;;
  while (len > 0 && available) {
    available = false;
    ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;
    Wire.beginTransmission(static_cast<int>(device));
    //send i2c START command
    Wire.write(memory);
    //Write memory address
    Wire.endTransmission();
    //send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true);
    //Request blockSize bytes from the device
    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
      available = true;
      rdBuf[memory - memstart] = Wire.read();
      memory++;
      len--;
    }
  }
}

I'm not quite sure what I'm doing wrong, any help would be much appreciated.

#Edit:

Below is an image of the current (minimal) setup. On the left there's the board with the ADC and multiplexer visible.

Arduino setup

The third set of wires goes to my protocol analyzer.

I'm working on a project where I have to communicate to several devices over I2C using a Genuino 101. Now I'm trying to get data off the bus but wire.available() stays at 0, even though my trace clearly shows there's data being sent.

 i2c trace

with the following timings

enter image description here

timings

Because the wire is never available my readbuf will always be empty.

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

I'm using the following code to read from the I2C bus.

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
  ushort memstart = memory;
  bool available = true;;
  while (len > 0 && available) {
    available = false;
    ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;
    Wire.beginTransmission(static_cast<int>(device));
    //send i2c START command
    Wire.write(memory);
    //Write memory address
    Wire.endTransmission();
    //send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true);
    //Request blockSize bytes from the device
    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
      available = true;
      rdBuf[memory - memstart] = Wire.read();
      memory++;
      len--;
    }
  }
}

I'm not quite sure what I'm doing wrong, any help would be much appreciated.

Edit:

Below is an image of the current (minimal) setup. On the left there's the board with the ADC and multiplexer visible.

Arduino setup

The third set of wires goes to my protocol analyzer.

Bumped by Community user
added 130 characters in body; edited title
Source Link
dda
  • 1.6k
  • 1
  • 12
  • 18

I2c I2C device Respondingresponding, but data is Nackednacked

i'mI'm working on a project where iI have to communicate to several devices over i2cI2C using the genuinoa Genuino 101. now i'm Now I'm trying to get data off the bus but wire.available()wire.available() stays at 0, even though my trace clearly shows theresthere's data being sent.

 i2c trace with

with the following timings [![timings][2]][2]

becauseenter image description here

timings

Because the wire is never available my readbuf will always be empty.

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

i'mI'm using the following codecode to read from the i2cI2C bus.

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
     ushort memstart = memory;
    bool available = true;;
    while (len > 0 && available) {
        available = false;
        ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;
 
    Wire.beginTransmission(static_cast<int>(device));    
    
 //send i2c START command
    Wire.write(memory);                  
    
 //Write memory adressaddress
    Wire.endTransmission();
    //send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true); 
    //Request blockSize bytes from the device
 
    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
        available = true;
        rdBuf[memory - memstart] = Wire.read();
        memory++;
        len--; 
        }
    }
}

i'mI'm not quite sure what i'mI'm doing wrong, any help would be much appreciated.

#edit#Edit:

belowBelow is an image of the current (minimal) setup, on. On the left there's the board with the ADC and Multiplexermultiplexer visible.

aruino SetupArduino setup

theThe third set of wires goes to my protocol analyzer,

https : //i stack imgur com/ZyYa6 png.

I2c device Responding, but data is Nacked

i'm working on a project where i have to communicate to several devices over i2c using the genuino 101. now i'm trying to get data off the bus but wire.available() stays 0, even though my trace clearly shows theres data being sent

 i2c trace with the following timings [![timings][2]][2]

because the wire is never available my readbuf will always be empty

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

i'm using the following code to read from the i2c bus

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
     ushort memstart = memory;
    bool available = true;;
    while (len > 0 && available) {
        available = false;
        ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;
 
    Wire.beginTransmission(static_cast<int>(device));       
 //send i2c START command
    Wire.write(memory);                     
 //Write memory adress
    Wire.endTransmission();
//send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true); 
//Request blockSize bytes from the device
 
    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
        available = true;
        rdBuf[memory - memstart] = Wire.read();
        memory++;
        len--; 
        }
    }
}

i'm not quite sure what i'm doing wrong, any help would be much appreciated

#edit:

below is an image of the current (minimal) setup, on the left there's the board with the ADC and Multiplexer visible.

aruino Setup

the third set of wires goes to my protocol analyzer,

https : //i stack imgur com/ZyYa6 png

I2C device responding, but data is nacked

I'm working on a project where I have to communicate to several devices over I2C using a Genuino 101. Now I'm trying to get data off the bus but wire.available() stays at 0, even though my trace clearly shows there's data being sent.

 i2c trace

with the following timings

enter image description here

timings

Because the wire is never available my readbuf will always be empty.

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

I'm using the following code to read from the I2C bus.

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
  ushort memstart = memory;
  bool available = true;;
  while (len > 0 && available) {
    available = false;
    ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;
    Wire.beginTransmission(static_cast<int>(device)); 
    //send i2c START command
    Wire.write(memory); 
    //Write memory address
    Wire.endTransmission();
    //send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true);
    //Request blockSize bytes from the device
    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
      available = true;
      rdBuf[memory - memstart] = Wire.read();
      memory++;
      len--;
    }
  }
}

I'm not quite sure what I'm doing wrong, any help would be much appreciated.

#Edit:

Below is an image of the current (minimal) setup. On the left there's the board with the ADC and multiplexer visible.

Arduino setup

The third set of wires goes to my protocol analyzer.

Bumped by Community user
Bumped by Community user
Bumped by Community user
added 208 characters in body
Source Link
Ron
  • 41
  • 5

i'm working on a project where i have to communicate to several devices over i2c using the genuino 101. now i'm trying to get data off the bus but wire.available() stays 0, even though my trace clearly shows theres data being sent

 i2c trace with the following timings timings[![timings][2]][2]

because the wire is never available my readbuf will always be empty

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

i'm using the following code to read from the i2c bus

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
     ushort memstart = memory;
    bool available = true;;
    while (len > 0 && available) {
        available = false;
        ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;

    Wire.beginTransmission(static_cast<int>(device));       
//send i2c START command
    Wire.write(memory);                     
 //Write memory adress
    Wire.endTransmission();
//send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true); 
//Request blockSize bytes from the device

    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
        available = true;
        rdBuf[memory - memstart] = Wire.read();
        memory++;
        len--; 
        }
    }
}

i'm not quite sure what i'm doing wrong, any help would be much appreciated

#edit:

below is an image of the current (minimal) setup, on the left there's the board with the ADC and Multiplexer visible.

aruino Setup

the third set of wires goes to my protocol analyzer,

https : //i stack imgur com/ZyYa6 png

i'm working on a project where i have to communicate to several devices over i2c using the genuino 101. now i'm trying to get data off the bus but wire.available() stays 0, even though my trace clearly shows theres data being sent

 i2c trace with the following timings timings

because the wire is never available my readbuf will always be empty

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

i'm using the following code to read from the i2c bus

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
     ushort memstart = memory;
    bool available = true;;
    while (len > 0 && available) {
        available = false;
        ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;

    Wire.beginTransmission(static_cast<int>(device));       
//send i2c START command
    Wire.write(memory);                     
 //Write memory adress
    Wire.endTransmission();
//send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true); 
//Request blockSize bytes from the device

    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
        available = true;
        rdBuf[memory - memstart] = Wire.read();
        memory++;
        len--; 
        }
    }
}

i'm not quite sure what i'm doing wrong, any help would be much appreciated

i'm working on a project where i have to communicate to several devices over i2c using the genuino 101. now i'm trying to get data off the bus but wire.available() stays 0, even though my trace clearly shows theres data being sent

 i2c trace with the following timings [![timings][2]][2]

because the wire is never available my readbuf will always be empty

Rdbuf[0] is: 0 Hex is: 0
Rdbuf[1] is: 0 Hex is: 0

i'm using the following code to read from the i2c bus

void i2cRead(unsigned char device, unsigned char memory, int len, unsigned char * rdBuf) {
     ushort memstart = memory;
    bool available = true;;
    while (len > 0 && available) {
        available = false;
        ushort blockSize;
    /*If the number of bytes is smaller than the block size, read that size*/
    (len < RD_BLCK_SIZE) ? blockSize = len : blockSize = RD_BLCK_SIZE;

    Wire.beginTransmission(static_cast<int>(device));       
//send i2c START command
    Wire.write(memory);                     
 //Write memory adress
    Wire.endTransmission();
//send i2c STOP command
    Wire.requestFrom(static_cast<int>(device), blockSize,true); 
//Request blockSize bytes from the device

    /* for every byte in the response add that byte to the read buffer */
    while (Wire.available() && (len != 0)) {
        available = true;
        rdBuf[memory - memstart] = Wire.read();
        memory++;
        len--; 
        }
    }
}

i'm not quite sure what i'm doing wrong, any help would be much appreciated

#edit:

below is an image of the current (minimal) setup, on the left there's the board with the ADC and Multiplexer visible.

aruino Setup

the third set of wires goes to my protocol analyzer,

https : //i stack imgur com/ZyYa6 png

Source Link
Ron
  • 41
  • 5
Loading