cancel
Showing results for 
Search instead for 
Did you mean: 

How to use the HAL I3C Library

sh.lee
Associate

Hello

I'm using NUCLEO-H503 to make an I3C master, and I have some issues.

1. I sent the ENTDAA command for I3C communication, but it does not go to HAL_I3C_STATE_READY.
The code written after several attempts is as follows.
HAL_I3C_Ctrl_DynAddrAssign(&hi3c1, &payload, I3C_RSTDAA_THEN_ENTDAA, timeout);
HAL_I3C_Ctrl_SetDynAddr(&hi3c1, DynAddr);
hi3c1.State = HAL_I3C_STATE_READY;
Is this a normal way to use the Library?

2. Please tell me how to read and write data on I3C slab.
For I2C, HAL_I2C_Master_Transmit and HAL_I2C_Master_Receive were used to communicate with the slave device.
Is there a function like this for I3C?
The function I found is HAL_I3C_Ctrl_Transmit, but do not work in my board.
Please let me know the functions you use for I3C communication and if you have a suitable example.

I am sorry for my poor English.

1 ACCEPTED SOLUTION

Accepted Solutions
Foued_KH
ST Employee

Hello @sh.lee , 

I suggest you this code : 

 

     /* Assign dynamic address processus */
      do
      {
         status = HAL_I3C_Ctrl_DynAddrAssign(&hi3c1, &payload[1], I3C_RSTDAA_THEN_ENTDAA, 5000);
        if (status == HAL_BUSY)
        {
          HAL_I3C_Ctrl_SetDynAddr(&hi3c1, DynAddr);
        }
          TargetDesc1.TARGET_BCR_DCR_PID = (uint64_t) payload;  
      }while (status == HAL_BUSY);

 

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

4 REPLIES 4
Pavel A.
Evangelist

Here are the examples. You can find them also in the "repository" directory on your PC where the STM32H5 cube firmware has been installed.

https://github.com/STMicroelectronics/STM32CubeH5/tree/main/Projects/NUCLEO-H503RB/Examples/I3C

STOne-32
ST Employee

Dear @sh.lee ,

Here is our application Note that describes I3C vs I2C and practical examples and use case . In I3C we have Controllers and Targets and no more the old terminology used in legacy I2C .

https://www.st.com/resource/en/application_note/an5879-introduction-to-i3c-for-stm32h5-series-mcu-stmicroelectronics.pdf

have a great day 

ciao 

Foued_KH
ST Employee

Hello @sh.lee , 

I suggest you this code : 

 

     /* Assign dynamic address processus */
      do
      {
         status = HAL_I3C_Ctrl_DynAddrAssign(&hi3c1, &payload[1], I3C_RSTDAA_THEN_ENTDAA, 5000);
        if (status == HAL_BUSY)
        {
          HAL_I3C_Ctrl_SetDynAddr(&hi3c1, DynAddr);
        }
          TargetDesc1.TARGET_BCR_DCR_PID = (uint64_t) payload;  
      }while (status == HAL_BUSY);

 

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.

Foued_KH
ST Employee

Hi @sh.lee , 

For I3C bus, there are four main types of devices :
• I3C main controller
• I3C secondary controller
• I3C targets
• Legacy I2C target


You can communicate using functions like : 
HAL_I3C_Ctrl_Transmit()
HAL_I3C_Ctrl_Receive()
HAL_I3C_Tgt_Transmit()
HAL_I3C_Tgt_Receive()

For more details you can refer to the I3C application note ( section 9 Examples of I3C communications )

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.