I have customized PCB based on BGM13P22, when i am trying to init my sensor on I2C0 bus (PC10_SDA#15, PC11_SCL#15) default configuration of soc_empty 2.11.5, I have code 1 for I2C_TransferInit. for I2C_Transfer loop, first time i have code 1, second code -1, then only -5.
Any person have an idea about the error ?
I have checked PCB circuit, it seems good.
Please find under the code steps (this code is working well dev kit)
after I2C_TransferInit result = 1
result = 1
result = -1
result = -5
result = -5
result = -5
....
infinite loop.
Have you any idea ?
If need more details, just tell me.
regards,
Abba
Discussion Forums
32-bit MCUs
Answered
Answered
it is better for you to upload your schematic, and let other know what I2C slave component you are try to communicate with.
to debug the I2C issue, usually you need a osciloscope to monitor the signal to see what happen.
0
Once you get a result that isn't i2cTransferInProgress or i2cTransferDone, there is no point continuing to call I2C_Transfer.
This will exit when appropriate:
/* Do a polled transfer */
result = I2C_TransferInit(I2C0, &i2cTransfer);
while (result == i2cTransferInProgress /* && timeout--*/) {
result = I2C_Transfer(I2C0);
}
Have you tried a simple I2C_FLAG_WRITE_READ ?
Also, a simple logic analyzer on the I2C bus can help find issues.
0
Please found the schematic of my custom PCB attached. Is there any mistakes ?
For debugging the i2C with a osciloscope can you suggest me a manual or tutorial ?
Yes i have tested Read_Write(I2C_FLAG_WRITE_READ) function its work well with my dev Kit, and it is making same error on my custom PCB.
This maybe not the root cause. my understanding is that the sensor use 1.8V level logic for I2C peripheral.
But it looks you are trying to connect the BGM (I guess 3.3V IOVDD) and sensor without level shifter.
0
Yes this is the mistakes. Can you suggest a type of level shifter ?
Thank you,
abba
0
Its is a little bit strange.
In the devKit of the sensor i have used 3.3v by mistakes, and this is working well (not good idea ...)
In my customized PCB i have changed the power supply of the sensor to 3.3v like i have made in the devkit, and it is not working. I have respected the schematic line in dev kit of the sensor.
Have i to investigate about another errors ?
Normally it have to work like on dev kit, What do you think ?
regards,
abba
0
In the devKit of the sensor i have used 3.3v by mistakes, and this is working well (not good idea ...)
I don't know the devKit well. do you mean there is a separate MCU (not BGM13P22) that could control the sensor on the devKit?
Regard the level shifter, you could search by google to get some device.
You'd better to use scope or logic analyzer to capture the I2C signal to see if it looks expected.
In the meantime, you may consider to contact with the sensor vendor to see if they have any advice.
0
I don't know the devKit well. do you mean there is a separate MCU (not BGM13P22) that could control the sensor on the devKit?
No, to evaluate the sensor, there is a PCB eval adapter which i have used with WSTK BGM13P22 to evaluate the sensor, and i have used 3.3v for powering and its working well.
regards,
Abba
Correct Answer
0
Then I would suggest you contact with sensor vendor (I guess ST) to see if they could help since there is no problem for the BGM13P22 to control the sensor (on the eval adapter).
0
Hi,
I have still the proplem with I2C communication.
I have takken a look on Logic Analyzer on the I2C traffic, I have found the attached communication sequences.
There one sequence which is correctly match to I2C communication, but the second one is little bit stange, what do you think about.
I2C software fault
Hi,
I have customized PCB based on BGM13P22, when i am trying to init my sensor on I2C0 bus (PC10_SDA#15, PC11_SCL#15) default configuration of soc_empty 2.11.5, I have code 1 for I2C_TransferInit. for I2C_Transfer loop, first time i have code 1, second code -1, then only -5.
Any person have an idea about the error ?
I have checked PCB circuit, it seems good.
Please find under the code steps (this code is working well dev kit)
void i2c_transfer(uint16_t device_addr, uint8_t cmd_array[], uint8_t data_array[], uint16_t cmd_len, uint16_t data_len, uint8_t flag)
{
// Transfer structure
I2C_TransferSeq_TypeDef i2cTransfer;
// Initialize I2C transfer
I2C_TransferReturn_TypeDef result;
i2cTransfer.addr = device_addr;
i2cTransfer.flags = flag;
i2cTransfer.buf[0].data = cmd_array;
i2cTransfer.buf[0].len = cmd_len;
// Note that WRITE_WRITE this is tx2 data
i2cTransfer.buf[1].data = data_array;
i2cTransfer.buf[1].len = data_len;
// Set up the transfer
result = I2C_TransferInit(I2C0, &i2cTransfer);
printLog("I2C_TransferInit result = %d \n\r", result);
// Do it until the transfer is done
while (result != i2cTransferDone)
{
if (result != i2cTransferInProgress)
{
}
result = I2C_Transfer(I2C0);
printLog(" result = %d \n\r", result);
}
// printLog("transfert done\r\n");
// BSP_LedSet(0);
}
Then i have in my log:
infinite loop.
Have you any idea ?
If need more details, just tell me.
regards,
Abba
it is better for you to upload your schematic, and let other know what I2C slave component you are try to communicate with.
to debug the I2C issue, usually you need a osciloscope to monitor the signal to see what happen.
Once you get a result that isn't i2cTransferInProgress or i2cTransferDone, there is no point continuing to call I2C_Transfer.
This will exit when appropriate:
Have you tried a simple I2C_FLAG_WRITE_READ ?
Also, a simple logic analyzer on the I2C bus can help find issues.
Please found the schematic of my custom PCB attached. Is there any mistakes ?
For debugging the i2C with a osciloscope can you suggest me a manual or tutorial ?
Yes i have tested Read_Write(I2C_FLAG_WRITE_READ) function its work well with my dev Kit, and it is making same error on my custom PCB.
regards,
Abba
This maybe not the root cause. my understanding is that the sensor use 1.8V level logic for I2C peripheral.
But it looks you are trying to connect the BGM (I guess 3.3V IOVDD) and sensor without level shifter.
Yes this is the mistakes. Can you suggest a type of level shifter ?
Thank you,
abba
Its is a little bit strange.
In the devKit of the sensor i have used 3.3v by mistakes, and this is working well (not good idea ...)
In my customized PCB i have changed the power supply of the sensor to 3.3v like i have made in the devkit, and it is not working. I have respected the schematic line in dev kit of the sensor.
Have i to investigate about another errors ?
Normally it have to work like on dev kit, What do you think ?
regards,
abba
I don't know the devKit well. do you mean there is a separate MCU (not BGM13P22) that could control the sensor on the devKit?
Regard the level shifter, you could search by google to get some device.
You'd better to use scope or logic analyzer to capture the I2C signal to see if it looks expected.
In the meantime, you may consider to contact with the sensor vendor to see if they have any advice.
No, to evaluate the sensor, there is a PCB eval adapter which i have used with WSTK BGM13P22 to evaluate the sensor, and i have used 3.3v for powering and its working well.
regards,
Abba
Hi,
I have still the proplem with I2C communication.
I have takken a look on Logic Analyzer on the I2C traffic, I have found the attached communication sequences.
There one sequence which is correctly match to I2C communication, but the second one is little bit stange, what do you think about.
regards,
Abba