cancel
Showing results for 
Search instead for 
Did you mean: 

Strange Output in I2C

CK.3
Associate III

I am using STM32F103C8T6 and developed on STM32CubeIDE. This equipment has  six similar  I2C boards (same ICs, same function)  connected to the master which are addressed accordingly. Each of these boards have 8 digital Inputs amounting to 8 bit value as data from each board. A few of this equipment were made and working fine for over 3 years period.

off recent, the new machine made, has a peculiar problem. When no digital inputs to any of these 6 boards, three boards (Boards 4, 5 & 6) give out an 8 bit integer value (eg: 182, 212, 247).

 Doubting the boards I switch places. Boards previous at 4,5 & 6 are now placed at 1, 2 & 3.  Despite switching places, boards 4, 5 & 6 give out same 182, 212 & 247. 

This means the problem is not board related. Then where are these values  creeping in from.

Help needed to solve this problem, have been struggling for last few days

Thanking in advance.

 

I2C IC PCA9554D used, data latched by 74HC573 operating at 400KHz-- I2C clk

 

HAL_I2C_Master_Transmit(&hi2c2,0x40, 0, 1,5); 
err = HAL_I2C_Master_Receive(&hi2c2,0x40, &data, 1,5);
if ( err != HAL_OK )
{
defect_PCB = 1;
}
else
PU_Array1_up = data;

HAL_I2C_Master_Transmit(&hi2c2,0x42, 0, 1,5); //42
err = HAL_I2C_Master_Receive(&hi2c2,0x42, &data, 1,5);
if ( err != HAL_OK )
{
defect_PCB = 2;
}
else
PU_Array2_up = data;

HAL_I2C_Master_Transmit(&hi2c2,0x44,0, 1,5); //44
err = HAL_I2C_Master_Receive(&hi2c2,0x44,&data, 1,5);
if ( err != HAL_OK )
{
defect_PCB = 3;
}
else
    PU_Array3_up = data;

HAL_I2C_Master_Transmit(&hi2c2,0x46, 0, 1,5); //0x46
err = HAL_I2C_Master_Receive(&hi2c2,0x46, &data, 1,5);
if ( err != HAL_OK )
{
defect_PCB = 4;
}
else
PU_Array4_up = data;

HAL_I2C_Master_Transmit(&hi2c2,0x48, 0, 1,5); //0x48
err = HAL_I2C_Master_Receive(&hi2c2,0x48, &data, 1,5);
if ( err != HAL_OK )
{
defect_PCB = 5;
}
else
PU_Array5_up = data;

HAL_I2C_Master_Transmit(&hi2c2,0x4A,0, 1,5); //0x4A
err = HAL_I2C_Master_Receive(&hi2c2,0x4A,&data, 1,5);
if ( err != HAL_OK )
{
defect_PCB = 6;
}
else
    PU_Array6_up = data;

 

 

2 REPLIES 2
TDK
Guru

> When no digital inputs to any of these 6 boards, three boards (Boards 4, 5 & 6) give out an 8 bit integer value (eg: 182, 212, 247).

Perhaps share more information on what this reading means and why you think the values are incorrect along with relevant connections and schematics.

 

> Despite switching places, boards 4, 5 & 6 give out same 182, 212 & 247. 

So probably something specific to your setup, not something in software applicable to all boards.

If you feel a post has answered your question, please click "Accept as Solution".

As @TDK said, need more detail on your setup - hardware, interconnections, code, etc

How to write your question to maximize your chances to find a solution.

 

Not clear whether your STM32 is the Master, or (one of) the slave(s) ?

Have you used an oscilloscope on the lines to check that the signals are good & clean ?

Have you used an analyser on the lines to see the actual data being sent between Master & Slave ?

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.