Question
Stm32h743ii 2 i2c independant bus
Dear all;
I have a *** question but it dont work can we have quantity 2 different i2c bus
1 is reconized but not the second bus
/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_LTDC_Init();
MX_QUADSPI_Init();
MX_FMC_Init();
MX_I2C2_Init();
MX_I2C4_Init();
MX_SPI1_Init();
MX_UART4_Init();
MX_USART1_UART_Init();
MX_TIM3_Init();
MX_DMA2D_Init();
/* USER CODE BEGIN 2 */
int P=10000;
HAL_TIM_PWM_Start(&htim3,TIM_CHANNEL_4);
//htim3.Instance->CCR1=50;
__HAL_TIM_SET_COMPARE(&htim3,TIM_CHANNEL_4, P);
HAL_StatusTypeDef result;
uint8_t i;
for (i=1; i<128; i++)
{
/* * the HAL wants a left aligned i2c address
* &hi2c1 is the handle
* (uint16_t)(i<<1) is the i2c address left aligned
* retries 2
* timeout 2*/
//ret = HAL_I2C_IsDeviceReady(&hi2c2, (uint16_t)(i<<1), 3, 5);
result = HAL_I2C_IsDeviceReady(&hi2c2, (uint16_t)(i<<1), 3, 5);
if (result != HAL_OK) // HAL_ERROR or HAL_BUSY or HAL_TIMEOUT
{
printf("."); // No ACK received at that address
}
if (result == HAL_OK)
{
printf("0x%X", i); // Received an ACK at that address
}
}
printf("\r\n");
HAL_StatusTypeDef result2;
uint8_t z;
for (z=1; z<128; z++)
{
/** the HAL wants a left aligned i2c address
* &hi2c1 is the handle
* (uint16_t)(i<<1) is the i2c address left aligned
* retries 2
* timeout 2
*/
//ret = HAL_I2C_IsDeviceReady(&hi2c2, (uint16_t)(i<<1), 3, 5);
result2 = HAL_I2C_IsDeviceReady(&hi2c4, (uint16_t)(z<<1), 3, 5);
if (result2 != HAL_OK) // HAL_ERROR or HAL_BUSY or HAL_TIMEOUT
{
printf("."); // No ACK received at that address
}
if (result2 == HAL_OK)
{
printf("0x%X", z); // Received an ACK at that address
}
}
printf("\r\n");