2020-06-11 06:33 AM
Hello,
I have my own board with stm32f0 and cr95hf
I use SPI to communicate with NFC module,
buy sometimes, like once out of a hundred, CR95HF stuck and the only way to solve the problem is to reset power.
I've tried SPI Reinit, sending reset cmd and etc. but still the same.
void CR95_Init(void) {
//SSI1 - RESET STATE and SSI0 - SET by default
uint8_t echo = 0;
IRQ_IN_HIGH();
osDelay(1);
IRQ_IN_LOW();
osDelay(1);
IRQ_IN_HIGH();
osDelay(15);
CHIP_SELECT();
HAL_SPI_Transmit(&hspi1, (uint8_t *)&CtrlBt_Reset, 1, 100);
CHIP_UNSELECT();
osDelay(100);
echo = NFC_Echo();
while (echo != 1) {
echo = NFC_Echo();
if (echo != 1) {
//Also trying to send to Hibernate state and reinit, but useless
Hibernate();
}
HAL_GPIO_TogglePin(LED_R_GPIO_Port, LED_R_Pin);
osDelay(100);
}
NFC_ProtocolSelect(Protocol_ISO_14443A,0x00);
Get_Sound(1, 150);
osDelay(1000);
}
Maybe I am doing something wrong or there is a solution to make it work without power reset
Thank you,
Anton
Solved! Go to Solution.
2020-06-12 05:31 AM
Hi,
X-CUBE-NFC3 is intended for ST25R95/CR95HF. This provides the proper support for the various NFC technologies, NDEF support, etc.. Of course some adaptations may be needed for integration with FreeRTOS (see @Slan post on FreeRTOS on this community)
For point 2), on my side I use SPI_POLARITY_LOW/SPI_PHASE_1EDGE an 1.5MHz (48MHz/32). What is the SYSCLK value on your board?
For point 6) if I understand well, sometimes the boot randomly fails due to CR95HF init sequence failing? See the init sequence below from X-CUBE-NFC3.
For point 7) on my side the initial state of IRQ_IN is low (see ioc file for the various pin setup)
Init sequence procedure
st25r95_nIRQ_IN_Pulse procedure
ResetChip procedure
SendEcho procedure
rgds
BT
2020-06-12 01:06 AM
Hi,
ST provides an NFC communication stack and a driver for ST25R95/CR95HF (see X-CUBE-NFC3 package). Default ports for NUCLEO-L476RG, NUCLEOF401RE or NUCLEO-F103RB are provided but it can easily be ported on STM32F0 series. I would recommend to use X-CUBE-NFC3. With this driver, I've never met a deadlock situation, so I believe the issue is elsewhere.
Regarding your issue, can you share more details:
Can you trace the following signals with a logic analyzer and send me the trace:
Rgds
BT
2020-06-12 04:03 AM
I was thinking that X-CUBE-NFC3 lib is only for new NFC modules, but I will try to use it
1) Only the task communicating with cr95hf
2)
hspi1.Init.CLKPolarity = SPI_POLARITY_HIGH;
hspi1.Init.CLKPhase = SPI_PHASE_2EDGE;
hspi1.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_64;
With CPOL = Low and CPHA = 1Edge it's working too
3) I don't use IRQ_OUT, but I will try
4) I don't use idle command
5) I don't use Card Emulation mode
6) Only during boot up
7) IRQ_IN initial state is HIGH
8) I guess I don't send SendReceive cmd, sorry don't have logic analyzer
I solve the problem, controlling VPS pin on CR95, and as I discovered CR95HF works even without VPS pulled to VCC,
I guess it gets power from SPI and UART.
So, now, with every board reset NFC module resets too (earlier it has stable voltage, even after board reset, NFC module didn't) and now it work's fine.
Thank you for the answer and good advices, I think I should work consider X-CUBE-NFC3 lib
2020-06-12 05:31 AM
Hi,
X-CUBE-NFC3 is intended for ST25R95/CR95HF. This provides the proper support for the various NFC technologies, NDEF support, etc.. Of course some adaptations may be needed for integration with FreeRTOS (see @Slan post on FreeRTOS on this community)
For point 2), on my side I use SPI_POLARITY_LOW/SPI_PHASE_1EDGE an 1.5MHz (48MHz/32). What is the SYSCLK value on your board?
For point 6) if I understand well, sometimes the boot randomly fails due to CR95HF init sequence failing? See the init sequence below from X-CUBE-NFC3.
For point 7) on my side the initial state of IRQ_IN is low (see ioc file for the various pin setup)
Init sequence procedure
st25r95_nIRQ_IN_Pulse procedure
ResetChip procedure
SendEcho procedure
rgds
BT