cancel
Showing results for 
Search instead for 
Did you mean: 

How to use I2C interface on the NFC06A1 / Nucleo-L476 board

JS Park1
Associate II

I am using Nucleo-L476 board and NFC06A1.

With the Free RTOS sample (ST25NFC_Embedded_Lib_ST25R3916_1.4.0, FreeRTOS_polling), I am aleady verified the NFC card operation with the SPI interface.

I tried to check the operation with I2C instead of SPI, but it did not work, so please inquire.

* Apply UM2616 documnet 3.5.1 item

1) H/W setup

• solder ST2 and ST4 jumpers

• solder R116 and R117 pull-up resistors

• remove the SPI solder bridge(R205)

• put the I²C solder bridge(R204)

2) S/W setup

• set RFAL_USE_I2C in the pre-processor

• rename USE_HAL_SPI_REGISTER_CALLBACKS by USE_HAL_I2C_REGISTER_CALLBACKS

* Status

Within the "st25r3916Initialize" function, it proceeds only to the "st25r3916ExecuteCommand( ST25R3916_CMD_SET_DEFAULT )", and does not proceed any further.

Inside the "BSP_I2C1_SequencialSend" function, the "hi2c->State" value does not change to HAL_I2C_STATE_READY.

To use I2C interface, is there anything else to add other than 3.5.1 items of the UM2616 article?

1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi,

I've tried on my side. Some extra modifications are needed in order to run the FreeRTOS demo in I2C mode:

  • in FreeRTOS_polling\Src\plf_adaptation.c, rename BSP_SPI1_IRQ_Callback to BSP_I2C1_IRQ_Callback in order to call the proper ISR code.
  • in FreeRTOS_polling\Src\nucleo_l476rg_bus.c, change Line 1038 HAL_NVIC_SetPriority(I2C1_EV_IRQn, 5, 5); to HAL_NVIC_SetPriority(I2C1_EV_IRQn, 0, 0);
  • in FreeRTOS_polling\Src\stm32l4xx_it.c: remove the SysTick_Handler fonction
  • in FreeRTOS_polling\Inc\FreeRTOSConfig.h add the following define: #define configUSE_NEWLIB_REENTRANT     1
  • in FreeRTOS_polling\Inc\FreeRTOSConfig.h change USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION from 1 to 0
  • In FreeRTOS_polling\Src\stm32l4xx_hal_timebase_tim.c add uwTickPrio = TickPriority; after line 50 HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, TickPriority ,0); 

Let me know whether this working on your side.

Rgds

BT

In order 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

7 REPLIES 7
Brian TIDAL
ST Employee

Hi,

UM2616 is related to the X-CUBE-NFC6 package where both SPI and I2C support is provided.

The  FreeRTOS_polling demo is provided in the ST25 embedded NFC library package and supports SPI communication (I2C code is included but the demo has been tested in SPI mode only).

What is the value of the R116 and R117 pullups resistors? (as far as I remember, the recommended value is 1k65).

What is the return code of BSP_I2C1_Init()?

Rgds

BT

In order 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.

As you remember, R116 and R117 used 1k 65.

The return code of BSP_I2C1_Init is BSP_ERROR_NONE.

Is there any sample project that uses I2C interface?

Brian TIDAL
ST Employee

Hi,

the PollingTagDetect demo in the  X-CUBE-NFC6 package uses the I2C demo (when  RFAL_USE_I2C is set and USE_HAL_SPI_REGISTER_CALLBACKS has been renamed to USE_HAL_I2C_REGISTER_CALLBACKS)

Rgds

BT

In order 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.
JS Park1
Associate II

Dear Brian,

As mentioned in the first post, I already rename USE_HAL_SPI_REGISTER_CALLBACKS to USE_HAL_I2C_REGISTER_CALLBACKS in the pre-processor section.​

Regards,

Hi,

this was just to indicate that by default the PollingTagDetect demo from the X-CUBE-NFC6 uses by default the SPI and that you will have to apply those changes if you want to move it to I2C for testing.

Although the FreeRTOS_polling demo has only been tested in SPI, I do not see obvious reason to have it not working in I2C with you changes.

Rgds

BT

In order 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.
Brian TIDAL
ST Employee

Hi,

I've tried on my side. Some extra modifications are needed in order to run the FreeRTOS demo in I2C mode:

  • in FreeRTOS_polling\Src\plf_adaptation.c, rename BSP_SPI1_IRQ_Callback to BSP_I2C1_IRQ_Callback in order to call the proper ISR code.
  • in FreeRTOS_polling\Src\nucleo_l476rg_bus.c, change Line 1038 HAL_NVIC_SetPriority(I2C1_EV_IRQn, 5, 5); to HAL_NVIC_SetPriority(I2C1_EV_IRQn, 0, 0);
  • in FreeRTOS_polling\Src\stm32l4xx_it.c: remove the SysTick_Handler fonction
  • in FreeRTOS_polling\Inc\FreeRTOSConfig.h add the following define: #define configUSE_NEWLIB_REENTRANT     1
  • in FreeRTOS_polling\Inc\FreeRTOSConfig.h change USE_CUSTOM_SYSTICK_HANDLER_IMPLEMENTATION from 1 to 0
  • In FreeRTOS_polling\Src\stm32l4xx_hal_timebase_tim.c add uwTickPrio = TickPriority; after line 50 HAL_NVIC_SetPriority(TIM1_UP_TIM16_IRQn, TickPriority ,0); 

Let me know whether this working on your side.

Rgds

BT

In order 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.

Dear Brian, ​

As a result of applying your guide, it works OK with I2C interface.

Regards,