Skip to main content
Associate II
November 25, 2025
Solved

How to switch to I2C mode on STEVAL 25R3916B board?

  • November 25, 2025
  • 4 replies
  • 609 views

Hi 

I am evaluating NFC function on your STEVAL 25R3916B board, but I would like to see how it works with the I2C interface. Currently, the default configuration is SPI.

I have downloaded STM32CubeIDE and STEVAL-25R3916B_V2.1.0 project code, but am not sure where should I put this definition "RFAL_USE_I2C", could you help me check where this macro needs to be placed?

Thanks 

Leo

Best answer by LeoWu

Hi Rene

After reintergate EXTI1_15, it can work normally through I2C interface.

 

Thanks for your help

Leo

4 replies

Brian TIDAL
Technical Moderator
November 25, 2025

Hi,

for I2C support, some HW modification on the STEVAL 25R3916B are needed:

  • I2C_EN: open J201 and close J200
  • SCL: open J205 and close J203
  • SDA: open J204, close J202

I2C pullup resistors are present on both the daugther board and the mother board. It might be needed to remove some of them.

On firmware side:

  • RFAL_USE_I2C compilation switch has to be defined (project properties / C-C++ build /MCU GCC Compiler / Preprocessor / Define symbols (-D))
  • replace the spi.c by the i2c.c file in the project
  • replace the spiInit(&hspi1); in the main by i2cInit(&hi2c2);
  • Initialize the I2C2 

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.
LeoWuAuthor
Associate II
November 26, 2025

Hi BT

Thanks for your reply, in terms of FW, there are some errror occured after added the changes you suggested.

In your FW, hi2c2 only can be used in st25_discovery.c, and  USE_NFCTAG needs to be defined for enabling hi2c2 related code.

could you help to check? or the FW I am using is not the latest one?

Thanks

Leo

Brian TIDAL
Technical Moderator
November 26, 2025

Hi Leo,

there was a typo in my previous answer: replace the spiInit(&hspi1); in the main by i2cInit(&hi2c2);

The I2C2 has to be initialized. This can be achieved by adding the proper MX_I2C2_Init() function inside the main.c file or by calling the BSP in the st25_discovery.c with the relevant define (in that case add  i2cInit(&hi2c2); before returning from STM32_I2C2_Init).

Also, make sure to enable the I2C2 even and I2C2 error interrupts.

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.
Explorer II
December 10, 2025

Hello,

I'm using the STEVAL-25R3916B board with the STEVAL-25R3916B_V2.1.0 demo firmware, and I’m trying to switch the interface from SPI to I2C.
I followed the same method described in this forum, but the I2C interface still does not work.

The firmware hangs during initialization inside InitializeRFAL(), specifically here:
here it's failing.

ret = HAL_I2C_Master_Sequential_Transmit_IT(pI2c(uint16_t)address, (uint8_t*)txBuf,txLen, txFlag );
 if( ret != HAL_OK )
 {
 return ret;
 }

The ST25R3916 never acknowledges on I2C

Hardware configuration (jumpers)

J200 closed (I2C_EN)
J201 open (SPI disabled)
J205 open
J203 closed
J204 open
J202 closed

I also tried removing and re-adding pull-up resistors on both the daughterboard and motherboard.
Board is powered from USB-mini (JP14 set to 4–2, S100 → 5V).

Firmware changes
I2C init (same as recommended in forum):

Clock configuration:

 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USB|RCC_PERIPHCLK_I2C2;
 PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLLSAI1;
 PeriphClkInit.I2c2ClockSelection = RCC_I2C2CLKSOURCE_SYSCLK;
 PeriphClkInit.PLLSAI1.PLLSAI1Source = RCC_PLLSOURCE_HSE;
 PeriphClkInit.PLLSAI1.PLLSAI1M = 1;
 PeriphClkInit.PLLSAI1.PLLSAI1N = 12;
 PeriphClkInit.PLLSAI1.PLLSAI1P = RCC_PLLP_DIV7;
 PeriphClkInit.PLLSAI1.PLLSAI1Q = RCC_PLLQ_DIV2;
 PeriphClkInit.PLLSAI1.PLLSAI1R = RCC_PLLR_DIV2;
 PeriphClkInit.PLLSAI1.PLLSAI1ClockOut = RCC_PLLSAI1_48M2CLK;
 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
 {
 _Error_Handler(__FILE__, __LINE__);
 while(1);
 }

 

HAL_I2C_MspInit() was updated in stm32l4xx_hal_msp.c (GPIO setup + I2C2 clock enable).
EXTI15 is disabled and I2C2 NVIC priority is set to 0,2.

Still no communication — the I2C bus stays stuck in BUSY state.

Request

Please confirm whether my jumper configuration for I2C mode on STEVAL-25R3916B is correct, or if any additional hardware steps are required.

Please confirm if the timing configuration and I2C2 clock source selection are correct for this board.

If possible, please provide a working I2C firmware binary for testing, so I can determine whether this is a hardware or firmware issue.

Thank you.

Rene Lenerve
ST Employee
December 10, 2025

Hello sk4,

Your jumper configuration sounds good. On my board I have only removed the pull-up resistors from the daughter board, without testing it with pull-up on both boards (however i think it may work too).

Take a look at the files I shared with Leo in my previous post if that helps, I also attached the binary to this message.

Kind Regards.

 
 

 

 

Explorer II
December 11, 2025
Hello,

I tested the IRQ priority set to 0xF, but it still doesn’t work on my board — it gets stuck during RFAL initialize.

Could you please share the exact modified source files you changed for switching from SPI to I²C?

I want to verify the configuration differences. I also tested the binary you shared earlier. I’m facing the same issue as Leo.

For debugging, could you please share a known-working binary so I can test it on my board?

Thank you.
Rene Lenerve
ST Employee
December 11, 2025

Hello,

Here are the modified files that uses the I²C bus with the ST25R3916. To ease the download I've made a zip (it includes the binary too).

I hope this can help you.

Kind Regards.