Not able to read RFID

I am using the Wio Lite W600 - ATSAMD21 Cortex-M0 Wireless Development Board. I got a RC522 RFID reader/writer. Link of the component

Connected these pins from RFID module to the wio board.

SDA - D32
SCK - D24
MOSI - D23
MISO - D22
RST - D5

I am trying to use the example code with SS_PIN set to 32 and RST set to 5. I do not get D32 or D5 variable in the sketch. Gives not declared in this scope error.

I get the following output on my serial console. mfrc522.PICC_IsNewCardPresent() keeps returning 0 and my loop exits from there. Can anyone help with fixing this?

Firmware Version: 0x92 = v2.0
Scan PICC to see UID, SAK, type, and data blocks...
Passed Self-Test

I suggest you test the SPI communication separately first.

I tried the following code from the examples


// DMA-based SPI buffer write.  This is transmit-only as written, i.e.
// not equivalent to Arduino's SPI.transfer() which both sends and
// receives a single byte or word.  Also, this is single-buffered to
// demonstrate a simple SPI write case.  See zerodma_spi2.ino for an
// example using double buffering (2 buffers alternating fill & transmit).

#include <SPI.h>
#include <Adafruit_ZeroDMA.h>
#include "utility/dma.h"

Adafruit_ZeroDMA myDMA;
ZeroDMAstatus    stat; // DMA status codes returned by some functions

// The memory we'll be issuing to SPI:
#define DATA_LENGTH 2048
uint8_t source_memory[DATA_LENGTH];

volatile bool transfer_is_done = false; // Done yet?

// Callback for end-of-DMA-transfer
void dma_callback(Adafruit_ZeroDMA *dma) {
  transfer_is_done = true;

void setup() {
  uint32_t t;
  pinMode(LED_BUILTIN, OUTPUT);   // Onboard LED can be used for precise
  digitalWrite(LED_BUILTIN, LOW); // benchmarking with an oscilloscope
  while(!Serial);                 // Wait for Serial monitor before continuing

  Serial.println("DMA test: SPI data out");


  Serial.println("Configuring DMA trigger");
#ifdef __SAMD51__
  // SERCOM2 is the 'native' SPI SERCOM on Metro M4
  // SERCOM4 is the 'native' SPI SERCOM on most M0 boards

  Serial.print("Allocating DMA channel...");
  stat = myDMA.allocate();

  Serial.println("Setting up transfer");
    source_memory,                    // move data from here
#ifdef __SAMD51__
    (void *)(&SERCOM2->SPI.DATA.reg), // to here (M4)
    (void *)(&SERCOM4->SPI.DATA.reg), // to here (M0)
    DATA_LENGTH,                      // this many...
    DMA_BEAT_SIZE_BYTE,               // bytes/hword/words
    true,                             // increment source addr?
    false);                           // increment dest addr?

  Serial.println("Adding callback");
  // register_callback() can optionally take a second argument
  // (callback type), default is DMA_CALLBACK_TRANSFER_DONE

  // Fill the source buffer with incrementing bytes
  for(uint32_t i=0; i<DATA_LENGTH; i++) source_memory[i] = i;

  // Start SPI transaction at 12 MHz
  SPI.beginTransaction(SPISettings(12000000, MSBFIRST, SPI_MODE0));

  Serial.println("Starting transfer job");
  t = micros();
  digitalWrite(LED_BUILTIN, HIGH);

  // Because we've configured a peripheral trigger (SPI), there's
  // no need to manually trigger transfer, it starts up on its own.
  stat = myDMA.startJob();

  // Your code could do other things here while SPI write happens!

  while(!transfer_is_done); // Chill until DMA transfer completes

  digitalWrite(LED_BUILTIN, LOW);
  t = micros() - t; // Elapsed time

  myDMA.printStatus(stat); // Results of start_transfer_job()

  Serial.print("Done! ");
  Serial.println(" microseconds");

void loop() { }

And I get the following output:

DMA test: SPI data out
Configuring DMA trigger
Allocating DMA channel...Status: OK
Setting up transfer
Adding callback
Starting transfer job
Status: OK
Done! 2742 microseconds

Since the status is printed after callback from the DMA I am guessing this is working?

The test program does not determine whether the data sent and received is reasonable or not.How do you guarantee that?