cancel
Showing results for 
Search instead for 
Did you mean: 

ST25 app not reading URI from NFC01A1

MasterHans
Associate II

I am using a STM32F411RE with a X-Nucleo-NFC01A1 (with the M24SR).

From the X-CUBE-NFC1 package ( https://www.st.com/en/embedded-software/x-cube-nfc1.html ), I adapted the code to my stm32F411RE.

Below is an extract of the main.c

So the TT4_Init() and TT4_WriteURI() returned SUCCESS since the LED 2 and 3 turned ON, However, I can't read the NFC tag using ST25 app, neither with "NFC tools" app from PlayStore.

Is it normal? What can I provide to help?

int main(void)
{
/* USER CODE BEGIN 1 */
sURI_Info URI;
/* 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 */
/* USER CODE BEGIN 2 */

// Init of the Nucleo Board led
BSP_LED_Init(LED2);
// Init of the Nucleo Board button
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);

// Init of the M24SR expansion board
initLED();

// Init of the Type Tag 4 component (M24SR)
// Thanks to a call to KillSession command during init no issue can occurs
// If customer modify the code to avoid Kill session command call,
// he must retry Init until succes (session can be lock by RF )
while (TT4_Init() != SUCCESS);

// Set the LED2 on to indicate Init done
HAL_GPIO_WritePin(GPIOB, GPIO_PIN_5, GPIO_PIN_SET); // led 2

// Prepare URI NDEF message content
strcpy(URI.protocol,URI_ID_0x01_STRING);
strcpy(URI.URI_Message,"st.com");
strcpy(URI.Information,"\0");

// First write NDEF
while (TT4_WriteURI(&URI) != SUCCESS);

// Set the LED3 on to indicate Programing done
HAL_GPIO_WritePin(GPIOA, GPIO_PIN_10, GPIO_PIN_SET); // led 3

/* USER CODE END 2 */

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1)
{
/* USER CODE END WHILE */

/* USER CODE BEGIN 3 */
}
/* USER CODE END 3 */
}

Here are the enabled modules from stm32f4xx_hal_conf.h. All callbacks from this file are disabled.

#define HAL_MODULE_ENABLED

/* #define HAL_CRYP_MODULE_ENABLED */
/* #define HAL_ADC_MODULE_ENABLED */
/* #define HAL_CAN_MODULE_ENABLED */
/* #define HAL_CRC_MODULE_ENABLED */
/* #define HAL_CAN_LEGACY_MODULE_ENABLED */
/* #define HAL_DAC_MODULE_ENABLED */
/* #define HAL_DCMI_MODULE_ENABLED */
/* #define HAL_DMA2D_MODULE_ENABLED */
/* #define HAL_ETH_MODULE_ENABLED */
/* #define HAL_ETH_LEGACY_MODULE_ENABLED */
/* #define HAL_NAND_MODULE_ENABLED */
/* #define HAL_NOR_MODULE_ENABLED */
/* #define HAL_PCCARD_MODULE_ENABLED */
/* #define HAL_SRAM_MODULE_ENABLED */
/* #define HAL_SDRAM_MODULE_ENABLED */
/* #define HAL_HASH_MODULE_ENABLED */
#define HAL_I2C_MODULE_ENABLED
/* #define HAL_I2S_MODULE_ENABLED */
/* #define HAL_IWDG_MODULE_ENABLED */
/* #define HAL_LTDC_MODULE_ENABLED */
/* #define HAL_RNG_MODULE_ENABLED */
/* #define HAL_RTC_MODULE_ENABLED */
/* #define HAL_SAI_MODULE_ENABLED */
/* #define HAL_SD_MODULE_ENABLED */
/* #define HAL_MMC_MODULE_ENABLED */
/* #define HAL_SPI_MODULE_ENABLED */
/* #define HAL_TIM_MODULE_ENABLED */
/* #define HAL_UART_MODULE_ENABLED */
/* #define HAL_USART_MODULE_ENABLED */
/* #define HAL_IRDA_MODULE_ENABLED */
/* #define HAL_SMARTCARD_MODULE_ENABLED */
/* #define HAL_SMBUS_MODULE_ENABLED */
/* #define HAL_WWDG_MODULE_ENABLED */
/* #define HAL_PCD_MODULE_ENABLED */
/* #define HAL_HCD_MODULE_ENABLED */
/* #define HAL_DSI_MODULE_ENABLED */
/* #define HAL_QSPI_MODULE_ENABLED */
/* #define HAL_QSPI_MODULE_ENABLED */
/* #define HAL_CEC_MODULE_ENABLED */
/* #define HAL_FMPI2C_MODULE_ENABLED */
/* #define HAL_FMPSMBUS_MODULE_ENABLED */
/* #define HAL_SPDIFRX_MODULE_ENABLED */
/* #define HAL_DFSDM_MODULE_ENABLED */
/* #define HAL_LPTIM_MODULE_ENABLED */
#define HAL_GPIO_MODULE_ENABLED
#define HAL_EXTI_MODULE_ENABLED
#define HAL_DMA_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_FLASH_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED

 

1 ACCEPTED SOLUTION

Accepted Solutions
MasterHans
Associate II

Hello Brian,

I was able to make it work : 

WhatsApp Image 2023-09-19 at 15.47.27.jpeg

The problem was linked to the configuration of the scripts: GPO function and I2C_GPO_INTERRUPT_ALLOWED parameter.

I wasn't using the GPO function to define in main.c from the example which configures the PINs A6 and A7 : 

 

 

 

/**

* @brief GPO initialization for M24SR

*  None

* @retval None

*/

void M24SR_GPOInit ( void )

{

GPIO_InitTypeDef GPIO_InitStruct;



/* GPIO Ports Clock Enable */

INIT_CLK_GPO_RFD();



/* Configure GPIO pins for GPO (PA6)*/

#ifndef I2C_GPO_INTERRUPT_ALLOWED

GPIO_InitStruct.Pin = M24SR_GPO_PIN;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;

HAL_GPIO_Init(M24SR_GPO_PIN_PORT, &GPIO_InitStruct);

#else

GPIO_InitStruct.Pin = M24SR_GPO_PIN;

GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;



HAL_GPIO_Init(M24SR_GPO_PIN_PORT, &GPIO_InitStruct);

/* Enable and set EXTI9_5 Interrupt to the lowest priority */

#if (defined USE_STM32F4XX_NUCLEO) || (defined USE_STM32F3XX_NUCLEO) || \

(defined USE_STM32L1XX_NUCLEO) || (defined USE_STM32F1XX_NUCLEO) || (defined USE_STM32L4XX_NUCLEO)

HAL_NVIC_SetPriority(EXTI9_5_IRQn, 3, 0);

HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);

#elif (defined USE_STM32L0XX_NUCLEO) || (defined USE_STM32F0XX_NUCLEO)

HAL_NVIC_SetPriority(EXTI4_15_IRQn, 3, 0);

HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);

#endif



#endif



/* Configure GPIO pins for DISABLE (PA7)*/

GPIO_InitStruct.Pin = M24SR_RFDIS_PIN;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(M24SR_RFDIS_PIN_PORT, &GPIO_InitStruct);

}

 

 

I changed the .ioc file from the CubeIDE project I changed the PA6 and PA7 from Reset_State to GPIO_Output. I don't know if it's relevant since I don't use the generated function MX_GPIO_Init(). Is it?

 

And TT4_Init() wasn't working because of an unsupported parameter. I found out that I2C_GPO_INTERRUPT_ALLOWED from drv_I2C_M24SR.h was set instead of I2C_GPO_SYNCHRO_ALLOWED.

A comment on the side of I2C_GPO_INTERRUPT_ALLOWED says ! NOT SUPPORTED BY MBED !.

 

Then it worked.

 

Many parameters have to be changed when using the examples, and it's hard to find them at first.

 

I add my main.c main.h and stm32f4xx_hal_msp.c to this reply for the next.

 

Thanks for the fast reply.

CU soon.

MH

View solution in original post

4 REPLIES 4
Brian TIDAL
ST Employee

 Hi,

using the Read memory in the ST25 app, what is the raw content of the NDEF File?

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.
MasterHans
Associate II

Hello Brian,

I meant that the app doesn't react at all to the NFC tag.

Where can I find Read memory in the ST25 NFC Tap app? I have the 3.9.0 version on Android 12.

I only have those pages on the app:

WhatsApp Image 2023-09-18 at 23.28.40.jpeg

WhatsApp Image 2023-09-18 at 23.28.40 (1).jpeg

WhatsApp Image 2023-09-18 at 23.28.40 (2).jpeg

WhatsApp Image 2023-09-18 at 23.41.34.jpeg

Clicking on Start NFC setting:

WhatsApp Image 2023-09-18 at 23.38.05.jpeg

 

 

Here is how I2C interface is defined:

 

void M24SR_I2CInit ( void )
{
	/* check if we re-init after a detected issue */
	if( hi2c1.Instance == M24SR_I2C)
	  HAL_I2C_DeInit(&hi2c1);

  /* Configure I2C structure */
  hi2c1.Instance 	     = M24SR_I2C;
  hi2c1.Init.AddressingMode  = I2C_ADDRESSINGMODE_7BIT;
#if defined (STM32F302x8)
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLE;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLE;
  hi2c1.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLE;
#elif defined (STM32F401xE)
  hi2c1.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
  hi2c1.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
  hi2c1.Init.NoStretchMode   = I2C_NOSTRETCH_DISABLED;
#endif
  hi2c1.Init.OwnAddress1     = 0;
  hi2c1.Init.OwnAddress2     = 0;
#if (defined USE_STM32F4XX_NUCLEO) || (defined USE_STM32L1XX_NUCLEO) || \
	  (defined USE_STM32F1XX_NUCLEO)
  hi2c1.Init.ClockSpeed      = M24SR_I2C_SPEED;
  hi2c1.Init.DutyCycle       = I2C_DUTYCYCLE_2;
#elif (defined USE_STM32F0XX_NUCLEO) || (defined USE_STM32L0XX_NUCLEO) || \
      (defined USE_STM32F3XX_NUCLEO) || (defined USE_STM32L4XX_NUCLEO)
  hi2c1.Init.Timing          = M24SR_I2C_SPEED;
#endif

	if(HAL_I2C_Init(&hi2c1) != HAL_OK)
  {
    /* Initialization Error */
    Error_Handler();
  }

}

 

 

 

Brian TIDAL
ST Employee

Hi,

the memory tab in the ST25 app is available once a tag has be discovered.

Can you try to read another tag and make sure that the NFC reader on the phone works properly?

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.
MasterHans
Associate II

Hello Brian,

I was able to make it work : 

WhatsApp Image 2023-09-19 at 15.47.27.jpeg

The problem was linked to the configuration of the scripts: GPO function and I2C_GPO_INTERRUPT_ALLOWED parameter.

I wasn't using the GPO function to define in main.c from the example which configures the PINs A6 and A7 : 

 

 

 

/**

* @brief GPO initialization for M24SR

*  None

* @retval None

*/

void M24SR_GPOInit ( void )

{

GPIO_InitTypeDef GPIO_InitStruct;



/* GPIO Ports Clock Enable */

INIT_CLK_GPO_RFD();



/* Configure GPIO pins for GPO (PA6)*/

#ifndef I2C_GPO_INTERRUPT_ALLOWED

GPIO_InitStruct.Pin = M24SR_GPO_PIN;

GPIO_InitStruct.Mode = GPIO_MODE_INPUT;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;

HAL_GPIO_Init(M24SR_GPO_PIN_PORT, &GPIO_InitStruct);

#else

GPIO_InitStruct.Pin = M24SR_GPO_PIN;

GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;

GPIO_InitStruct.Pull = GPIO_NOPULL;

GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;



HAL_GPIO_Init(M24SR_GPO_PIN_PORT, &GPIO_InitStruct);

/* Enable and set EXTI9_5 Interrupt to the lowest priority */

#if (defined USE_STM32F4XX_NUCLEO) || (defined USE_STM32F3XX_NUCLEO) || \

(defined USE_STM32L1XX_NUCLEO) || (defined USE_STM32F1XX_NUCLEO) || (defined USE_STM32L4XX_NUCLEO)

HAL_NVIC_SetPriority(EXTI9_5_IRQn, 3, 0);

HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);

#elif (defined USE_STM32L0XX_NUCLEO) || (defined USE_STM32F0XX_NUCLEO)

HAL_NVIC_SetPriority(EXTI4_15_IRQn, 3, 0);

HAL_NVIC_EnableIRQ(EXTI4_15_IRQn);

#endif



#endif



/* Configure GPIO pins for DISABLE (PA7)*/

GPIO_InitStruct.Pin = M24SR_RFDIS_PIN;

GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;

GPIO_InitStruct.Pull = GPIO_NOPULL;

HAL_GPIO_Init(M24SR_RFDIS_PIN_PORT, &GPIO_InitStruct);

}

 

 

I changed the .ioc file from the CubeIDE project I changed the PA6 and PA7 from Reset_State to GPIO_Output. I don't know if it's relevant since I don't use the generated function MX_GPIO_Init(). Is it?

 

And TT4_Init() wasn't working because of an unsupported parameter. I found out that I2C_GPO_INTERRUPT_ALLOWED from drv_I2C_M24SR.h was set instead of I2C_GPO_SYNCHRO_ALLOWED.

A comment on the side of I2C_GPO_INTERRUPT_ALLOWED says ! NOT SUPPORTED BY MBED !.

 

Then it worked.

 

Many parameters have to be changed when using the examples, and it's hard to find them at first.

 

I add my main.c main.h and stm32f4xx_hal_msp.c to this reply for the next.

 

Thanks for the fast reply.

CU soon.

MH