cancel
Showing results for 
Search instead for 
Did you mean: 

CR95HF SPI read value shifting

SMahm.2
Associate II

Hi,

I am working with the CR95HF on the xnucleo nfc03a1 and using a custom Atmega328 board.

I can communicate with the CR95HF but the read sequence is kind of like in a shift register. See attached figures.

Fig 1: I am only reading the device ID, notice how the bytes shift for some reason.

Fig 2: I also read echo and all the bytes are out of order.

The code I am using is as follows:

startCR95HF(); transmitSPI(0x00); transmitSPI(0x01); transmitSPI(0x00); stopCR95HF(); // send ID command
pollCR95HF();
		
startCR95HF(); transmitSPI(0x02);    // read ID
transmitUart0('ID ');
for (int i = 0; i<17; i++){
	transmitUart0(receiveSPI()); 
	}
stopCR95HF();
		
startCR95HF(); transmitSPI(0x00); transmitSPI(0x55); transmitSPI(0x00); stopCR95HF();
pollCR95HF();   // send command for echo 
 
startCR95HF(); transmitSPI(0x02); transmitUart0(receiveSPI()); stopCR95HF(); // read echo

0693W000007Z6qzQAC.png0693W000007Z6qkQAC.png 

Any idea what might be causing this?

Thanks in advance

Regards,

Salman

1 ACCEPTED SOLUTION

Accepted Solutions
SMahm.2
Associate II

Hi Brian,

I will make a more stable PCB and report back if this solves the issue, at the moment, its connected through long jumper wires so maybe that might be an issue.

Regards,

Salman

View solution in original post

2 REPLIES 2
Brian TIDAL
ST Employee

Hi Salman,

can you connect a logic analyzer on the SPI (CS, CLK, MISO, MOSI) + IRQ_IN + IRQ_OUT and provide a log file? This would help to see the precise SPI timings

Is the MCU connected to the X-NUCLEO-NFC03A1 through a PCB or through wires? If using wires, make sure to have short cables and to have a good connection.

I guess startCR95HF() implements the management of the SPI Chip Select, make sure to add the tSU(NSS) setup time delay.

Can you check that the UART trace is reliable and does not lose data due to some overflow/overrun?

I would recommend that pollCR95HF() polls the IRQ_OUT pin rather than using the software poll command (see §5.9 in ST25R95 Data sheet)

X-CUBE-NFC3 provides a a hardware independent scalable NFC communication stack on top of a driver for the ST25R95/CR95HF. This can easily be ported to non ST MCU. I would recommend to use this library and to port it on your MCU in order to reduce the development cost/effort on your side.

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.
SMahm.2
Associate II

Hi Brian,

I will make a more stable PCB and report back if this solves the issue, at the moment, its connected through long jumper wires so maybe that might be an issue.

Regards,

Salman