Hi @FBL,
I got the code working. Here is how I modified the code generated by MX2.
In the HAL_I3C_CTRL_SetConfig function I commented out the LL_I3C_Enable invocation. Since in that same function LL_I3C_SetMode is invoked CRINIT bit is set and EN flag is not set because I commented out LL_I3C_Enable.
In mx_i3c1_init I added the following workaround code that pulls up the SDA line temporarily and then sets the EN bit. After that SDA goes back to the normal push-pull configuration. This sequence ensures that SDA is HIGH when EN is set.
/**
[GPIO Pin] ------> [Signal Name] ------> [Labels]
PB5 ------> I3C1_SDA ------> PB5
**/
// ----------- BEGIN Workaround ----------------
// Temporarily enable SDA pull-up
gpio_config.mode = HAL_GPIO_MODE_ALTERNATE;
gpio_config.output_type = LL_GPIO_OUTPUT_OPENDRAIN;
gpio_config.pull = HAL_GPIO_PULL_UP;
gpio_config.speed = HAL_GPIO_SPEED_FREQ_HIGH;
gpio_config.alternate = HAL_GPIO_AF_3;
HAL_GPIO_Init(PB5_PORT, PB5_PIN, &gpio_config);
// Enable I3C
LL_I3C_Enable(I3C_GET_INSTANCE(&hI3C1));
// ----------- END Workaround ----------------
gpio_config.mode = HAL_GPIO_MODE_ALTERNATE;
gpio_config.output_type = HAL_GPIO_OUTPUT_PUSHPULL;
gpio_config.pull = HAL_GPIO_PULL_NO;
gpio_config.speed = HAL_GPIO_SPEED_FREQ_HIGH;
gpio_config.alternate = HAL_GPIO_AF_3;
HAL_GPIO_Init(PB5_PORT, PB5_PIN, &gpio_config);
The MX2 Bus usage is set to “I3C pure bus”, the I3C frequency is set to the maximum value of 12500 and the Duty cycle I3C is set to 50.
Reset the Controller, reset the Target (in my case another STM32) then initiate DAA. It works every time. If I power on the Controller and the Target together and then perform DAA everything works fine as well.
Regards,
Gil