cancel
Showing results for 
Search instead for 
Did you mean: 

cr95hf doesn't respond to anti-collision

ASoen
Associate

I have an nRF52 DK and a CR95HF development board from Mikroe (https://www.mikroe.com/rfid-click) and I'm using the Nordic SPI SDK version 14.2.0

I have managed to get the device to communicate with the CR95HF and got through the calibration phase, where at each step it correctly responds to the requests.

I am developing on Linux.

However, after sending REQA, to which it responds correctly for my MIFARE Classic card that I'm using as a test device.

I then have to send Anti-Collison, to which it doesn't respond and only after sending many of these same requests repeatedly do I get an 0x81 response.

The only other response I've gotten is 0x82 which is "invalid protocol" per CR95HF documentation. 

The reqa request and anti-collision look as follows:

/* REQA from tag */
 
uint8_t m_txreqa_buf[5] = { 0x00, 0x04, 0x02, 0x26, 0x07 };
uint8_t m_rxreqa_buf[11] = { 0x00 };
 
/* Anti-collision */
 
uint8_t m_txantcl_buf[6] = { 0x00, 0x04, 0x03, 0x93, 0x20, 0x08 };
uint8_t m_rxantcl_buf[10] = { 0x00 };
 
/*   rfid_send_reqa()
 */
void rfid_send_reqa()
{
   send_cmd(m_txreqa_buf, sizeof(m_txreqa_buf), m_rxreqa_buf, sizeof(m_rxreqa_buf), 1);
}
 
 
/*   rfid_send_anticl()
 *   Send anti-collision sequence to tag
 */
 
void rfid_send_anticl()
{
   send_cmd(m_txantcl_buf, sizeof(m_txantcl_buf), m_rxantcl_buf, sizeof(m_rxantcl_buf), 5);
}
 
/*   send_cmd()
 *   Send SPI command in 'tx' of length 'tx_len' and pass a 'rx' buffer of 'rx_len'
 *   for the device to write its response to. 
 *   Wait for 'delay_ms' milliseconds after finishing this transaction, if required.
 */
void send_cmd(uint8_t *tx, size_t tx_len, uint8_t *rx, size_t rx_len, int delay_ms)
{
   nrf_drv_gpiote_out_clear(RFID_CS_PIN);
 
   spi_xfer_done = false;
 
   APP_ERROR_CHECK(nrf_drv_spi_transfer(&spi, tx, tx_len, rx, rx_len));
 
  /* Do not wait for transfer done, as we are in a timer that will pick up the event to handle the return from spi */
 
   nrf_delay_ms(delay_ms);
}

I then wait on an interrupt from the rfid device to tell me its ready to have data read, at which time I do an spi transfer with a read command. 

The REQA comes back as follows (I have verified this is correct)

<info> app: SEND_REQA

<info> app: Pin change detected!

<info> app: Transfer completed

<info> app: Received:

<info> app: 0D 80 05 04 00 28 00 00|.....(..

<info> app: 00 00 00              |...

<info> app: RECV_REQA

```

whereas the anti-collision just does this:

```

<info> app: SEND_ANTI_CL

<info> app: SEND_ANTI_CL

<info> app: SEND_ANTI_CL

<info> app: SEND_ANTI_CL

<info> app: SEND_ANTI_CL

<info> app: SEND_ANTI_CL

... (elided, same as above)

<info> app: SEND_ANTI_CL

<info> app: SEND_ANTI_CL

<info> app: Pin change detected!

<info> app: Transfer completed

<info> app: Received:

<info> app: 0E 81 00 00 00 00 00 00|........

<info> app: 00 00                 |..

<info> app: RECV_ANTI_CL

Eventually just erroring out with a seemingly undefined error.

Per what I can tell I am sending the correct Anti-Collision request for the protocol I am using. I am reading a MIFARE Classic 1K ISO 14443-3A. 

I'm not seeing why the device doesn't respond to the anti-collision request.

If anyone has any ideas, I would be grateful?

1 REPLY 1
Brian TIDAL
ST Employee

Hi,

see https://community.st.com/s/question/0D50X0000B0xPsbSQE/cr95hf-error-code-0x81 for a similar issue.

0x81 means invalid command code but in the present case this probably means that some data are corrupted on the SPI link.

A SPI trace would be needed to do a timing analysis.

Rgds

BT

ST25 NFC / RFID Readers – Xx95HF Series

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.