cancel
Showing results for 
Search instead for 
Did you mean: 

Interrupt issue at freertos

yusufekici
Associate II

Hello,

We are using ST25R3920B as NFC reader for our project. The communication is through SPI between mcu and NFC reader. 

I configured a GPIO as an interrupt and wrote a callback function for this GPIO.

At the end of the callback function, interrupt flag is cleared. Inside this callback function, a task is notified. Before jumping to the task, interrupt flag is cleared at the the end of the callback function.

The task I notified will call the "st25r3916CheckForReceivedInterrupts" function.

However, I use this GPIO's status (HIGH, LOW) in order to read some registers in the task. Because I clear interrupt, I am not able to read this pin as HIGH. Operating system is FreeRTOS. That's why, I can not put this read operation inside Callback function because I use SPI_send function in this read operation.

 

Problematic part where the GPIO's status is read inside "st25r3916CheckForReceivedInterrupts" function by reading "platformGpioIsHigh".

If interrupt flag is not cleared, the system will be stuck in the interrupt. If I clear the flag , I can never read the GPIO's status as high at the notified task.

 

I made the implementation based on this documents refering to the freertos part.

There is no issue when we implemented the driver at baremetal system. So we tought that we might miss something related to freertos part. 

https://www.st.com/en/embedded-software/stsw-st25r-lib.html#documentation

 

How can I make read operation without clearing the interrupt flag? Which part should I investigate to resolve this issue?

 

ST25R3920B

This discussion has been locked for participation. If you have a question, please start a new topic in order to ask your question
1 ACCEPTED SOLUTION

Accepted Solutions
Brian TIDAL
ST Employee

Hi,

the S25R3920B IRQ line stays high until the S25R3920B interrupt registers are read. Therefore, the GPIO connected to the S25R3920B IRQ line should not be set low when clearing the MCU interrupt flag.

A FreeRTOS demo is provided inside the ST25R Embedded library for ST25R3916. The interrupt pending bit is cleared inside HAL_EXTI_IRQHandler before the callback BSP_SPI1_IRQ_Callback is called. This callback notifies the ISR task though a call to  vTaskNotifyGiveFromISR. Then the ISR task runs the st25r3916Isr() that reads he ST25R3916 interrupt registers through st25r3916CheckForReceivedInterrupts until the GPIO is set to low by the ST25R3916.

Which MCU is being used in your application? Make sure the GPIO is configured as external interrupt with rising edge trigger detection with no pull-up, no pull down.

Also, feel free to reuse the existing FreeRTOS demo from the ST25R Embedded library.

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

2 REPLIES 2
Brian TIDAL
ST Employee

Hi,

the S25R3920B IRQ line stays high until the S25R3920B interrupt registers are read. Therefore, the GPIO connected to the S25R3920B IRQ line should not be set low when clearing the MCU interrupt flag.

A FreeRTOS demo is provided inside the ST25R Embedded library for ST25R3916. The interrupt pending bit is cleared inside HAL_EXTI_IRQHandler before the callback BSP_SPI1_IRQ_Callback is called. This callback notifies the ISR task though a call to  vTaskNotifyGiveFromISR. Then the ISR task runs the st25r3916Isr() that reads he ST25R3916 interrupt registers through st25r3916CheckForReceivedInterrupts until the GPIO is set to low by the ST25R3916.

Which MCU is being used in your application? Make sure the GPIO is configured as external interrupt with rising edge trigger detection with no pull-up, no pull down.

Also, feel free to reuse the existing FreeRTOS demo from the ST25R Embedded library.

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

Thanks for support . We checked again the FreeRtos demo and added a missing part.

It works now.