Question
[SOLVED] --- BSP_I2C_Read() hang my STM32 app ---
I am developping a touch screen user interface to control an audio preampl and dac.
I have no problems with I2C bus to set the registers of CT7302PL and ES9018K2M but if I try to read a single register the application hang.
This is my I2C configuration.
//######################################################################################
//# DAC SECTION
//######################################################################################
void SetReg_ES9018K2M()
{
unsigned char reg7, reg11;
BSP_I2C_Write(0x90, 8, 0b10011001); // GPIO1 & GPIO2 as INPUT based on reg#21
switch (inputsel)
{
case 0:
//write_ext_eeprom( 1,0b10001100); old ?
BSP_I2C_Write(0x90, 1, 0b10000100);
BSP_I2C_Write(0x90, 21, 0b00000000);
BSP_I2C_Write(0x90, 11, 0b00000000);
break;
case 1:
BSP_I2C_Write(0x90, 1, 0b10000001);
BSP_I2C_Write(0x90, 21, 0b01010000);
BSP_I2C_Write(0x90, 11, 0b00110000); // 3
break;
case 2:
BSP_I2C_Write(0x90, 1, 0b10000001);
BSP_I2C_Write(0x90, 21, 0b01010000);
BSP_I2C_Write(0x90, 11, 0b01000000); // 4
break;
}
reg11 = BSP_I2C_Read(0x90, 11);
}
void BSP_I2C_Init()
{
#define I2C_ADDRESS 0x3c
#define I2C_TIMING 0x00B1112E
hi2c1.Instance = I2C1;
hi2c1.Init.Timing = I2C_TIMING;
hi2c1.Init.OwnAddress1 = I2C_ADDRESS;
hi2c1.Init.OwnAddress1 = 0x78; // an unused address
hi2c1.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
hi2c1.Init.OwnAddress2 = 0;
hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
hi2c1.Init.NoStretchMode = I2C_NOSTRETCH_DISABLE;
I2Cx_Init(&hi2c1);
}