Skip to main content
Associate II
June 23, 2023
Solved

How to use the HAL I3C Library

  • June 23, 2023
  • 6 replies
  • 4360 views

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.

This topic has been closed for replies.
Best answer by Foued_KH

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

6 replies

Pavel A.
June 23, 2023

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 Technical Moderator
June 23, 2023

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
Foued_KHBest answer
ST Employee
July 6, 2023

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.
sh.leeAuthor
Associate II
February 1, 2024

When I used the code above, I was stuck in hi3c1.State=HAL_I3C_STATE_BUSY_DAA.

What should I do to return to HAL_I3C_STATE_READY?

Foued_KH
ST Employee
February 7, 2024

Did you get this error also when using IT mode ? (I3C_Controller_ENTDAA_IT example in the cubefw)

 

Could you check the available examples in the STM32H5 CubeFW : 
STM32Cube_FW_H5_V1.1.1\Projects\NUCLEO-H503RB\Examples\I3C


And for for more information about I3C communication you can check the I3C AN section 9.8Introduction to I3C for STM32H5 series MCU - Application note


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
July 6, 2023

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.