arduino - RFid click board with CR95HF microcontroller refuses to respond -


i have arduino rfid click board mikro electronika. click board has microcontroller cr95hf microcontroller. according datasheet when send echo command should poll , read returned value 0x55. if use command idn (0x01) , send datalength of zero, should id of controller back.

according serial monitor returns 0 (is there wrong variable?). according logic analyzer returns exact same thing send (when send 3, returns 3, when send 55, returns 55). seems microcontroller doesn't react send or , it's broken?

so right looks able send through spi.transfer() function, retrieve seems problem.

here's code:

#include <spi.h>  // 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 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 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 cr95hf, ready?   byte tmp = 0;    digitalwrite(_sspin, low);   while (!tmp)   {    delay(100);     //note: whatever send, same thing back. send 3, tmp 3. send 8, tmp 8.     spi.transfer(0x03);     tmp = spi.transfer(0);     // serial.print("polling: ");     serial.println(tmp, bin);      tmp = (tmp & 0x08) >> 3;      delay(100);    }   digitalwrite(_sspin, high);   delay(20);    // ready 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);  // believe not possible on arduino or not nessaccery, tried 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 write/read   delay(20);    spi.begin();   // 2 mhz max clock speed, significant bit first, spi_mode unknown (probably 0, tried)   spi.begintransaction(spisettings(2000000, msbfirst, spi_mode0));    wakeupcr95hf();    while(!echoresponse())   {     wakeupcr95hf();   }  // serial.println("connection established"); }  void loop() { } 


Comments

Popular posts from this blog

Ansible - ERROR! the field 'hosts' is required but was not set -

customize file_field button ruby on rails -

SoapUI on windows 10 - high DPI/4K scaling issue -