cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H503RB I3C Target Address NAK Problem

BRIAN_LAI
Associate II

I am using EVB NUCLEO-H503RB with I3C Target feature.

I have successfully assign a dynamic address (0x50) to this I3C Target:

kh_placeholder.pngkh_placeholder.pngHowever, I could not get ACK from this Target with Address 0x50:

kh_placeholder.png 

Below are my configure, is there anything missing for responding the address?

/**
  * @brief I3C1 Initialization Function
  * @param None
  * @retval None
  */
static void MX_I3C1_Init(void)
{
 
  /* USER CODE BEGIN I3C1_Init 0 */
 
  /* USER CODE END I3C1_Init 0 */
 
  I3C_FifoConfTypeDef sFifoConfig = {0};
  I3C_TgtConfTypeDef sTgtConfig = {0};
 
  /* USER CODE BEGIN I3C1_Init 1 */
  /* I3C1 interrupt Init */
 
  /* USER CODE END I3C1_Init 1 */
  hi3c1.Instance = I3C1;
  hi3c1.Mode = HAL_I3C_MODE_TARGET;
  hi3c1.Init.TgtBusCharacteristic.BusAvailableDuration = 0x1e;
//  if (HAL_I3C_Init(&hi3c1) != HAL_OK)
//  {
//    Error_Handler();
//  }
 
  /** Configure FIFO
  */
  sFifoConfig.RxFifoThreshold = HAL_I3C_RXFIFO_THRESHOLD_1_4;
  sFifoConfig.TxFifoThreshold = HAL_I3C_TXFIFO_THRESHOLD_1_4;
  sFifoConfig.ControlFifo = HAL_I3C_CONTROLFIFO_DISABLE;
  sFifoConfig.StatusFifo = HAL_I3C_STATUSFIFO_DISABLE;
 
//  if (HAL_I3C_SetConfigFifo(&hi3c1, &sFifoConfig) != HAL_OK)
//  {
//    Error_Handler();
//  }
 
  /** Configure Target
  */
  sTgtConfig.Identifier = 0;
  sTgtConfig.MIPIIdentifier = 0;
  sTgtConfig.CtrlRoleRequest = DISABLE;
  sTgtConfig.HotJoinRequest = DISABLE;
  sTgtConfig.IBIRequest = DISABLE;
  sTgtConfig.IBIPayload = DISABLE;
  sTgtConfig.IBIPayloadSize = HAL_I3C_PAYLOAD_1_BYTE;
  sTgtConfig.MaxReadDataSize = 0;
  sTgtConfig.MaxWriteDataSize = 0;
  sTgtConfig.CtrlCapability = DISABLE;
  sTgtConfig.GroupAddrCapability = DISABLE;
  sTgtConfig.DataTurnAroundDuration = HAL_I3C_TURNAROUND_TIME_TSCO_LESS_12NS;
  sTgtConfig.MaxReadTurnAround = 0;
  sTgtConfig.MaxDataSpeed = HAL_I3C_GETMXDS_FORMAT_1;
  sTgtConfig.MaxSpeedLimitation = DISABLE;
  sTgtConfig.HandOffActivityState = HAL_I3C_HANDOFF_ACTIVITY_STATE_0;
  sTgtConfig.HandOffDelay = DISABLE;
  sTgtConfig.PendingReadMDB = DISABLE;
//  if (HAL_I3C_Tgt_Config(&hi3c1, &sTgtConfig) != HAL_OK)
//  {
//    Error_Handler();
//  }
  /* USER CODE BEGIN I3C1_Init 2 */
   HAL_I3C_Init(&hi3c1);
   HAL_I3C_SetConfigFifo(&hi3c1, &sFifoConfig);
   HAL_I3C_Tgt_Config(&hi3c1, &sTgtConfig);
  /* USER CODE END I3C1_Init 2 */
 
}

 

1 ACCEPTED SOLUTION

Accepted Solutions

hello @BLAI.1​ ,

There is no way to communicate I2C controller with I3C target features, you can just work on I3C bus to improve the features of the I2C interface preserving some backward compatibility.

  • Legacy I2C controller is not supported in I3C bus.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

View solution in original post

3 REPLIES 3
Foued_KH
ST Employee

Hello @BLAI.1​ ,

I agree with you that the target has already a dynamic address:

The DEVR0 register value is 161 = 0xA1 which means : DA = 0x50 and DAVAL = 1 .

Make sure that you are using the private read/write or direct read/write in a correct way !

Could please you share your code ( controller side ) ?

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @KHALSI_Foued​ ,

I have some new discover.

I found my I3C Target could ACK to the I3C Controller.

But it could not response correctly to the Legacy I2C Controller, even both of them are sending same signal:


_legacyfs_online_stmicro_images_0693W00000dDgzhQAC.pngWhy is it happening?

Is there any way to fix it?

By the way, below are my code for I3C Controller:

/* Context buffer related to Frame context, contain different buffer value for a communication */
I3C_XferTypeDef aContextBuffers[3];
 
/* Array contain targets descriptor */
TargetDesc_TypeDef *aTargetDesc[1] = \
                          {
                            &TargetDesc1,       /* DEVICE_ID1 */
                          };
 
/* Descriptor for private data transmit */
/* Buffer used for transmission */
uint8_t aTxBuffer[2] = {0};
uint8_t T_aTxBuffer[0xFF] = {0};
 
/* Buffer used for reception */
uint8_t aRxBuffer[0xFF];
uint8_t T_aRxBuffer[0xFF];
uint64_t  Dyn_aRxBuffer[0xFF];
 
/* Buffer used by HAL to compute control data for the Private Communication */
uint32_t aControlBuffer[0xF];
 
I3C_PrivateTypeDef aPrivateDescriptor[2] = \
                                          {
											//Controller Read Write
                                            {TARGET1_DYN_ADDR, {aTxBuffer, 2}, {NULL, 0}, HAL_I3C_DIRECTION_WRITE},
                                            {TARGET1_DYN_ADDR, {NULL, 0}, {aRxBuffer, 2}, HAL_I3C_DIRECTION_READ},
                                          };
										  
int main(void)
{
  /* USER CODE BEGIN 1 */
 
  /* USER CODE END 1 */
 
  /* MCU Configuration--------------------------------------------------------*/
 
  /* Reset of all peripherals, Initializes the Flash interface and the Systick. */
  HAL_Init();
 
  /* USER CODE BEGIN Init */
 
  /* USER CODE END Init */
 
  /* Configure the system clock */
  SystemClock_Config();
 
  /* USER CODE BEGIN SysInit */
 
  /* USER CODE END SysInit */
 
  /* Initialize all configured peripherals */
  MX_GPIO_Init();
  MX_I3C1_Init();
  MX_I3C2_Init();
  MX_ICACHE_Init();
  /* USER CODE BEGIN 2 */
  /* Enable Interrupt for Dynamic Address Assignment on I3C Target */
  HAL_I3C_ActivateNotification(&hi3c1, NULL, HAL_I3C_IT_DAUPDIE);
 
  /* Handle Dynamic Address Assignment (Applying CCC 0x07 to I3C Bus) */
  HAL_StatusTypeDef result = HAL_ERROR;
  HAL_I3C_Ctrl_DynAddrAssign(&hi3c2, Dyn_aRxBuffer, I3C_ONLY_ENTDAA, 100);
  result = HAL_I3C_Ctrl_SetDynAddr(&hi3c2, TARGET1_DYN_ADDR);
 
  LL_mDelay(2);
 
  /* Prepare Transmit context buffer with the different parameters */
  aTxBuffer[0] = 0x80;
  aTxBuffer[1] = 0xCC;
  aContextBuffers[0].CtrlBuf.pBuffer = aControlBuffer;
  aContextBuffers[0].CtrlBuf.Size    = 1;
  aContextBuffers[0].TxBuf.pBuffer   = aTxBuffer;
  aContextBuffers[0].TxBuf.Size      = 2;
 
  /* Prepare a test frame to send */
  HAL_I3C_AddDescToFrame(&hi3c2,
                         NULL,
                         &aPrivateDescriptor[0],
                         &aContextBuffers[0],
                         aContextBuffers[0].CtrlBuf.Size,
                         I3C_PRIVATE_WITHOUT_ARB_STOP);
 
  //HAL_I3C_Ctrl_Transmit_IT(&hi3c2, &aContextBuffers[0]);
  HAL_I3C_Ctrl_Transmit(&hi3c2, &aContextBuffers[0], 50);
  LL_mDelay(10);
  /* USER CODE END 2 */
 
  /* Infinite loop */
  while (1)
  {
 
    /* USER CODE BEGIN 3 */
  }
  /* USER CODE END 3 */
}

hello @BLAI.1​ ,

There is no way to communicate I2C controller with I3C target features, you can just work on I3C bus to improve the features of the I2C interface preserving some backward compatibility.

  • Legacy I2C controller is not supported in I3C bus.

Foued

To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.