Skip to main content
alper ozel
Associate II
December 6, 2017
Question

STM32F072RBT Nucleoboard I2C not working properly

  • December 6, 2017
  • 1 reply
  • 976 views
Posted on December 06, 2017 at 09:18

The original post was too long to process during our migration. Please click on the attachment to read the original post.
    This topic has been closed for replies.

    1 reply

    john doe
    Senior III
    December 6, 2017
    Posted on December 06, 2017 at 13:09

    HAL wants the I2C address shifted one bit to the left.  Instead of ADXL_ADD_RD, try

    (uint16_t)ADXL_ADD_RD << 1

    The ADXL also wants the chip select pulled high in order to choose i2c.  I did not examine that part of your code, I just noticed it in the data sheet.

    alper ozel
    Associate II
    December 7, 2017
    Posted on December 07, 2017 at 07:14

    Thanks you suggestion was to the point but the working code is like this if other users struggle the the same problem I have, they should try like this:

    HAL_I2C_Master_Transmit(&hi2c1, ADXL_ADD << 1, TX_DATA, 1, 200);

    HAL_I2C_Master_Receive(&hi2c1, (ADXL_ADD | 0x01) << 1, RX_BUFFER, 1, 200);

    I don't know why but using read and write addresses seperately doesn't work. This way however, it works.