You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/12/14 15:04:09 UTC

[GitHub] [incubator-nuttx] jskusk opened a new issue #5003: i2c write garbage on tiva EK-TM4C1294XL board.

jskusk opened a new issue #5003:
URL: https://github.com/apache/incubator-nuttx/issues/5003


   I'm attending to connect MPU6050 sensor (MPU60x0) sensor to a TI TIVA EK-TM4C1294XL board using i2c and facing some troubles when writing two i2c_msg_s messages such as when adding a register address to a reg8 write. For the specific sensor one would typical write two some power control registers and such could be accomplished using the i2c tool as such
   
   i2c set -b 2 -a 0x68 -f 100000 -r 0x6b 0x00
   
   But instead of transmitting 0x00 it becomes 0x04. Using gdb i found that the 0x04 is the value next to the actually 0x00 uint8_t and my oscilloscope confirm that the board actually transmit 0x04 and it is not due to noise and so. Without the device register address (-r) the output is correct ex.
   
   i2c set -b 2 -a 0x68 -f 100000 0x00
   
   My temporary fix to i2c tool is by patching apps/system/i2c/i2c_set.c with
   
   ```
   190a191
   >   
   196a198,199
   >   uint8_t buf[3];
   > 
   233a237,240
   >                 buf[0] = (uint8_t) regaddr;
   >                 buf[1] = (uint8_t) value;
   >             buf[2] = (uint8_t) value << 8;
   >           msg[1].buffer = &buf;
   235c242,243
   <           ret = i2cdev_transfer(fd, msg, 2);
   ---
   >                 msg[1].length += 1;
   >           ret = i2cdev_transfer(fd, &msg[1], 1);
   ```
   In above patch I simply avoid having i2cdev_transfer function looping the two msgs (i2cdev_transfer(fd, msg, 2)) and instead create a buffer with regaddr and value and point msg[1].buffer to this local buf and transmit it using i2cdev_transfer(fd, &msg[1], 1).
   
   Same bug occur for the mpu60x0.c driver that uses i2c_write function with the exception that it transmitted 0x30. Using the same approach as above temporary solved it. I tried digging further down the stack but my skills ended here. I guess is that the bug is within the tiva implementation and I will try comping to a stm32 board to further narrow it down.
   
   Anyone have a idea why or help me debug?
   
   I use master branch @ bd7cb1aae5e2416f6858b47f4dbfe7ae470e072b
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org