2022-01-19 05:32 PM
We are communicating with the st25r3916 chip normally.
But after about 14 minutes,
The value of the IRQ pin is maintained at HIGH.
You fall into an infinite loop in the function st25r3916CheckForReceivedInterruptts().
What is the problem ?
please I'd appreciate it if you let me know.
Infinite loop.
while( platformGpioIsHigh( ST25R391X_INT_PORT, ST25R391X_INT_PIN ) )
{
st25r3916ReadMultipleRegisters( ST25R3916_REG_IRQ_MAIN, iregs, ST25R3916_INT_REGS_LEN );
irqStatus |= (uint32_t)iregs[0];
irqStatus |= (uint32_t)iregs[1]<<8;
irqStatus |= (uint32_t)iregs[2]<<16;
irqStatus |= (uint32_t)iregs[3]<<24;
}
Solved! Go to Solution.
2022-01-21 02:00 AM
Hi,
I had a look to your EXTI9_5_IRQHandler code and in my opinion this can cause some side effect: if a new interrupt is triggered just after line #4, it will be cleared by the HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8); in line #6 of the code snippet. Therefore I would recommend the following implementation:
void EXTI9_5_IRQHandler(void)
{
/* USER CODE BEGIN EXTI9_5_IRQn 0 */
/* USER CODE END EXTI9_5_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */
st25r3916Isr();
/* USER CODE END EXTI9_5_IRQn 1 */
}
Note: make sure to #include "st25R3916_irq.h" to avoid compiler warning.
Can you also double confirm that:
Rgds
BT
2022-01-20 12:31 AM
Hi,
can you share some details about your setup:
Would it be possible to connect a logic analyzer on the SPI (CLK, MISO, MOSI, SS) + IRQ_3916 and share the trace?
Thanks
Rgds
BT
2022-01-20 12:48 AM
Hi KHyun.1,
on 3916 we have never observed the IRQ maintained at high / IRQ flood. Pleae provide a logic analyzer trace as requested by Brian.
I have seen also your other post Why does spi communication fall into an infinite loop? (st.com): Is that one now obsolete as the hang is one layer higher? If so, please comment on the other one.
Thanks, Ulysses
2022-01-20 01:12 AM
#define RFAL_VERSION (uint32_t)0x02000aU /*!< RFAL Current Version: v2.0.10 */
It is a custom board and the mcu uses stm32f407.
RTOS is not implemented.
Sorry, there is currently no logic analyzer.
2022-01-20 01:17 AM
Hi,
some additional questions:
is the IRQ line shared with another device? can you share the schematics ? How is configured the GPIO connected to the IRQ_3916?
Thanks
Rgds
BT
2022-01-20 01:18 AM
It was not that the spi communication went into an infinite loop, but that it stopped at the above IRQ.
Occurs when ATR is transmitted (RFAL_NFC_STATE_POLL_TECHDETECT)
It does not occur in case of DataExcharge. (RFAL_NFC_STATE_DATAEXCHANGE)
2022-01-20 01:23 AM
Sorry for not speaking English.
It is a schematic and It's directly connected to the GPIO of the chip.
2022-01-20 01:54 AM
Hi,
can you check that PA8 GPIO is configured as:
Can you also check the platformProtectST25RComm() and platformUnprotectST25RComm macros (in plateform.h) to make sure the NVIC_DisableIRQ and NVIC_EnableIRQ use the correct EXTI9_5_IRQn interrupt (or its alias IRQ_3916_EXTI_IRQn if the PA8 has been labelled as IRQ_3916)?
#define platformProtectST25RComm() do{ globalCommProtectCnt++; __DSB();NVIC_DisableIRQ(IEXTI9_5_IRQn);__DSB();__ISB();}while(0) /*!< Protect unique access to ST25R communication channel - IRQ disable on single thread environment (MCU) ; Mutex lock on a multi thread environment */
#define platformUnprotectST25RComm() do{ if (--globalCommProtectCnt==0U) {NVIC_EnableIRQ(IEXTI9_5_IRQn);} }while(0) /*!< Unprotect unique access to ST25R communication channel - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
OR:
#define platformProtectST25RComm() do{ globalCommProtectCnt++; __DSB();NVIC_DisableIRQ(IRQ_3916_EXTI_IRQn);__DSB();__ISB();}while(0) /*!< Protect unique access to ST25R communication channel - IRQ disable on single thread environment (MCU) ; Mutex lock on a multi thread environment */
#define platformUnprotectST25RComm() do{ if (--globalCommProtectCnt==0U) {NVIC_EnableIRQ(IRQ_3916_EXTI_IRQn);} }while(0) /*!< Unprotect unique access to ST25R communication channel - IRQ enable on a single thread environment (MCU) ; Mutex unlock on a multi thread environment */
Can you also check that st25r3916Isr() is called inside the EXTI9_5_IRQHandler
void EXTI9_5_IRQHandler(void)
{
/* USER CODE BEGIN EXTI9_5_IRQn 0 */
/* USER CODE END EXTI9_5_IRQn 0 */
HAL_GPIO_EXTI_IRQHandler(GPIO_PIN_8);
/* USER CODE BEGIN EXTI9_5_IRQn 1 */
st25r3916Isr();
/* USER CODE END EXTI9_5_IRQn 1 */
}
Rgds
BT
2022-01-20 02:56 AM
Hi,
NFC_SS is denoted as an input from MCU side in the schematic, it should be an output.
BR, Ulysses
2022-01-20 04:22 AM
Hi,
likely an issue of missing locking as indicated by Brian: Inside technology detection the timing is denser and the chances of interrupts happening in vulnerable places is higher.
I saw in the other thread that you want to drive two 3916s. What you are doing here is it still with only one 3916 or did you start adapting the code?
All suggestions we are doing now are more of guesswork. A logic analyzer trace would allow us to give more definite answers.
BR, Ulysses