title: RFid click board with CR95HF microcontroller refuses to respond
body: <p>I have an Arduino with a RFid click board from Mikro Electronika. The click board has a microcontroller CR95HF microcontroller. According to the <a href="http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/DM00025644.pdf" rel="nofollow">datasheet</a> when I send the ECHO command I should poll and then read the returned value 0x55. If I use the command IDN (0x01) and send a datalength of zero, I should get the ID of the controller back. </p>
  
  <p>According to the serial monitor it only returns zero (is there something wrong with the variable?).
  According to the logic analyzer it returns the exact same thing as what was send
  (when I send 3, it returns 3, when i send 55, it returns 55).
  It seems the microcontroller doesn't react anything I send it or it does and it's just broken?</p>
  
  <p>So right now it looks like it is able to send something through the spi.transfer() function, but the retrieve seems to be a problem.</p>
  
  <p>Here's my code:</p>
  
  <pre><code>#include &lt;SPI.h&gt;
  
  // CR95HF: Write, poll, read, reset
  #define   CMD             0x00
  #define   POLL            0x03
  #define   READ            0x02
  #define   RESET           0x01
  
  #define   ECHO            0x55
  
  const int _SSpin = 10; // CS
  const int _IRQpin = 6; // INT_out : 2, INT_in : 6, tried both, barely to no difference
  //const int _SI0pin = A3;
  //const int _SI1pin = A0;
  
  void WakeupCR95HF()
  {
   //Serial.println("Wake up!");
   digitalWrite(_IRQpin, LOW);
   delay(100);
   digitalWrite(_IRQpin, HIGH);
   delay(100);
  }
  
  bool EchoResponse()
  {
      byte len = 0;
  
    // write to CR95HF
    digitalWrite(_SSpin, LOW);
    delay(100);
    SPI.transfer(0x00);
  
    // Serial.print("echo code: ");
    // Serial.println(ECHO);
  
    SPI.transfer(0x55);
    //SPI.transfer(0x00);
    digitalWrite(_SSpin, HIGH);
    //delay(1000);
  
    // poll to CR95HF, is it ready?
    byte tmp = 0;
  
    digitalWrite(_SSpin, LOW);
    while (!tmp)
    {
     delay(100);
      //Note: whatever I send, I get the same thing back. I send 3, then tmp is 3. I send 8, tmp is 8.
      SPI.transfer(0x03);
      tmp = SPI.transfer(0);
  
     // Serial.print("Polling: ");
      Serial.println(tmp, BIN);
  
      tmp = (tmp &amp; 0x08) &gt;&gt; 3;
  
      delay(100); 
    }
    digitalWrite(_SSpin, HIGH);
    delay(20);
  
    // ready to write
    byte res = 0;
  
    digitalWrite(_SSpin, LOW);
    delay(100);
    SPI.transfer(0x02);
    res = SPI.transfer(0);
  
   // Serial.print("reading: ");
   // Serial.println(res);
  
    delay(100);
    digitalWrite(_SSpin, HIGH);
    delay(100);
  
    if (res == ECHO)
    {
      return true;
    }
   return false;
  }
  
  void setup() {
  Serial.begin(9600);
  
  // I believe this is not possible on Arduino or not nessaccery, tried it anyway, no change
  // pinMode(_SI0pin, OUTPUT);
  // pinMode(_SI1pin, OUTPUT);
  
   pinMode(_SSpin, OUTPUT);
   pinMode(_IRQpin, OUTPUT);
  
  // digitalWrite(_SI0pin, HIGH);
  // digitalWrite(_SI1pin, LOW);
  
    digitalWrite(_IRQpin, HIGH); // wakeup
    delay(20);
    digitalWrite(_SSpin, HIGH);  // slave select, low = ready to write/read
    delay(20);
  
    SPI.begin();
    // 2 MHz max clock speed, Most Significant Bit first, SPI_MODE unknown (probably 0, all were tried)
    SPI.beginTransaction(SPISettings(2000000, MSBFIRST, SPI_MODE0));
  
    WakeupCR95HF();
  
    while(!EchoResponse())
    {
      WakeupCR95HF();
    }
   // Serial.println("Connection established");
  }
  
  void loop() {
  }
  </code></pre>