I cant get values with I2C using HAL_Library .I use HAL_I2C_Mem_Read and I cant manage ,maybe my adress wrong I didnt understand please help
LCD_Init(_LCD_4BIT, _LCD_FONT_5x8, _LCD_2LINE );
HAL_GPIO_WritePin(GPIOD, LED1_Pin, GPIO_PIN_SET);
while((a & 0x80) == 0)
HAL_GPIO_WritePin(GPIOD, LED2_Pin, GPIO_PIN_SET);
HAL_GPIO_WritePin(GPIOD, LED3_Pin, GPIO_PIN_SET);
sonuc = (int16_t)(((uint16_t)out<<8) | out);
sonuc1 = sonuc*0.004F;
You might have more answers if you :
So, first does HAL_I2C_IsDeviceReady(&hi2c1,ADXL345_I2C_Adress,5,100) returns HAL_OK ?
Also it seems that most examples set the clockrate before checking if the device is ready, like this :
to_send = ACCEL_RATE_100KHZ;HAL_I2C_Mem_Write(I2C_device, ACCEL_ADDR, ACCEL_BW_RATE, sizeof(uint8_t), to_send, sizeof(uint8_t), 100);HAL_I2C_IsDeviceReady(I2C_device, ACCEL_ADDR, 1, 100);
Using 0x53 for the Accelerator address.
This might help you :
The examples here github.com/.../ADXL345.cpp appear to simply do a 6 byte-read from the DATA_X0 address. No conversion done. That said, the official documentation state that in I²C mode, you might need to offset the register address in some conditions. But I have no idea what these conditions are : www.analog.com/static/imported-files/data_sheets/ADXL345.pdf Try a simple 6 bytes read from DATA_X0 and see if you get something useful. github.com/.../ADXL345.cpp
View all questions in Embedded forum