2020-09-07 02:17 AM
I am using STM32L496ZG nucleo board for interface MEMS MPL3115A2 Sensor using I2C interface . First i am scanning I2C device and find attached device too.But after scanning device whenever i tried to read Who am i register , i don't receive correct data and receive 0X00 instead of register value.
Datasheet for breakout board -https://cdn-shop.adafruit.com/datasheets/1893_datasheet.pdf
Code for Scanning device and read Who am i register using STM32Cubeide.
/*define--------------------------------------*/
/*Scan device----------------------------*/
/*Read who am i register--------------*/
And this is settings to configure I2C in STM32cubMX.
This Sensor breakout board is working with other controllers finely ,But not with this STM32 board .
Please help me out from this . Is there any changes need to do in Hardware or in configuration?
2020-09-11 02:48 AM
Hi @Community member ,
I added STM32 topics for more support. I would suggest you to check the operating voltage of MPL3115A2. 3.3V should be OK. Please note that on the sensor datasheet is reported that "This board/chip uses I2C 7-bit address 0x60", so you have to make sure you are communicating I2C 7-bit (seems OK from your screen). You can double-check whether this is true if the device address you get with the scanning is actually 0x60.
-Eleon
2020-09-17 08:30 AM
Hi @Community member ,
do you have any news on this topic from your side?
-Eleon
2024-07-22 03:24 AM
I have the same issue, any update on this topic?
2024-08-20 06:09 AM
I am using the Nucleo STM32L432KC, but it should also work with any other Nucleo. You must use the
HAL_I2C_Mem_Read
function. Then it should work.
Device address: 0x60
Who am I register: 0x0C
Expected return value: 0xC4
uint8_t addr = 0x60 << 1;
uint8_t trans_data[1] = {0x0C}; //0x0C is the "Who am i" register
uint8_t rec_data[1] = {0x00};
while (1) {
//works:
HAL_I2C_Mem_Read(&hi2c1, addr, trans_data[0], sizeof(trans_data) / sizeof(trans_data[0]), rec_data,sizeof(rec_data) / sizeof(rec_data[0]) , 1000);
//does not work:
HAL_I2C_Master_Transmit(&hi2c1, addr, trans_data, sizeof(trans_data) / sizeof(trans_data[0]), 1000);
HAL_I2C_Master_Receive(&hi2c1,addr, rec_data, sizeof(rec_data) / sizeof(rec_data[0]), 1000);
break;
}