cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F072RBT Nucleoboard I2C not working properly

alper ozel
Associate II
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.
2 REPLIES 2
john doe
Lead
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.

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.