This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Hardware errors using the cc1101 and cc1190 extender evaluation module

Other Parts Discussed in Thread: CC1101, CC1190, TEST2, CC1100

Hi!

I'm fairly new to this module, but I'm using the cc1101 and cc1190 evaluation module to drive some LEDs with a receiver. I've written some initial code for Arduino, but will eventually switch to a different microcontroller, do please just respond on the current code and problem :). I've written the code in order to burst access the registers and set these using the values I got from RFstudio. However when I read the values using the MISO channel, sometimes it returns the right value (as I check the first register in order to see if the RF module got the right info. My setting is that the firdt register should be 0x29 and it returned that yesterday and now it seems to return F all the time. A couple of hours ago it still worked. I'm lost and it seems like these errors come at random times.I've written the header properly as it worked a couple of hours ago.

Can anyone please help me??\

Kind regards,

Imara

  • Sooo I've been messing around with this for quite some days now. In the mean time I got the RF module to work together with the arduino I'm using and I've been able to send and receive signals via SPI using this code:

    /*   
     *   SPI communication with the RF module for Dutchband
     *   Initial prototype, needs further communication with DMX
     *   By Imara Speek
     */

    // inslude the SPI library:
    #include <SPI.h>


    /* SPI configution for slave RF device (arduino is Master) when including SPI.h
     * const int MOSI = 11;  // Master Output, slave input. Serial In RF  
     * const int MISO = 12;  // Master input, slave output, Serial Out RF
     * const int SCK = 13;   // Serial clock
     */

    const int ss = 10;       // Slave select the RF module

    // set pins to drive the modes of the RF
    const int HGM = 2;      // Pin to steer the HGM
    const int LNA_EN = 3;   // Pin to steer the LNA_EN
    const int PA_EN = 4;    // Pin to steer the PA_EN

    // Current bytes for debugging
    byte red = 0x00;  
    byte green = 0x38;
    byte blue = 0x30;
    byte white = 0x00;
    byte sleep = 0x00;
    byte func = 0x00;

    // Debugging
    byte statusbyte = 0x00;
    byte statusbyte1 = 0x00;
    byte statusbyte2 = 0x00;
    byte compare1 = 0x00;
    byte compare2 = 0x00;

    // Actual header to use
    byte configheader = 0x40;   // 01000000 to burst write to address 0x00, or config addresses
    byte readheader = 0x80;     // read slave input at address 10000000
    byte burstheader = 0x7F;     // header for transmit burst access

    byte address = 0x95;         // standard address necessary

    // Command strobes
    byte STX = 0x35;            // 00110101 STX command strobe to initiate TX mode
    byte SFTX = 0x3B;           // Flush the TX FIFO
    byte SFRX = 0x3A;           // Flush the RX FIFO
    byte SIDLE = 0x36;          // Set into idle state
    byte SNOP = 0x3D;           // SNOP to check status byte
    byte SRES = 0x30;           // RESET
    byte SFSTXON = 0x31;        // turn into TX state and calibrate
    byte SCAL = 0x33;           // calibrate frequency

    void setup()
    {
      Serial.begin(9600);      // Set the baud rate for the monitor
      Serial.print("setup\n");
      // set the slaveRF as an output:
      // pinMode (HGM, OUTPUT);
      // pinMode (PA_EN, OUTPUT);
      // pinMode (LNA_EN, OUTPUT);

      pinMode (ss, OUTPUT);                // Declare the slave as an output
      SPI.begin();                         // Sets the inputs and outputs, pulling SCK and MOSI low and SS high

      // initialize SPI:
      SPI.setBitOrder(MSBFIRST);           // Set the mode according to the RF slave (most significant bit first)
      SPI.setDataMode(SPI_MODE0);          // Base value clock is 0, data captured on rising edge (CPOL = 0, CHPA = 0)
      SPI.setClockDivider(SPI_CLOCK_DIV16); // This is default, has to be chosen according to freq board
     
    /* Manual initialization power-on reset
      digitalWrite(SCK, HIGH);
      digitalWrite(MOSI, LOW);
      digitalWrite(ss, LOW);
      delayMicroseconds(50);
      digitalWrite(ss, HIGH);
      digitalWrite(ss, LOW);
      statusbyte = SPI.transfer(SNOP);
      delay(10);
      while(statusbyte & 0x80){};           // wait untill MISO goes low and clock is stabilized
      SPI.transfer(SRES);
      while(SPI.transfer(SNOP) & 0x80){};   // reset complete and in idle mode
     */
     
      // Wake up the RF module
      digitalWrite(ss, LOW);
      delay(10);
      //while (digitalRead(MISO)){};
      digitalWrite(ss, HIGH);
     
      digitalWrite(ss, LOW);
      //delay(10);
      while (digitalRead(MISO)){};
      statusbyte = SPI.transfer(SIDLE);    // Set the RF in IDLE state
      digitalWrite(ss, HIGH);
     
      // DEBUG
      Serial.print("status in initialization after SIDLE = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");

      // initialize RF as a transmitter in high gain
      // TX_HGM();

      // send register settings
      sendRegisters();

      // wake up the wristband
      wakeUp();
    }

    void loop()
    {
      // TODO write recognition of DMX signal

      // Send the data with header to the wristband by using the RF
      sendData(burstheader, address, red, green, blue, white, sleep, func);

    }

    void sendData(byte header,byte address, byte red, byte green, byte blue, byte white, byte sleep, byte func)
    {
        // issue sidle command
      digitalWrite(ss, LOW);
      delay(10);
      SPI.transfer(SIDLE);
      digitalWrite(ss, HIGH);

      // read number of bytes
      digitalWrite(ss, LOW);
      delay(10);
      statusbyte = SPI.transfer(SNOP);
      digitalWrite(ss, HIGH);

      // check number of bytes and flush if it is more than 0
      if ((statusbyte & 00001111) > 0){
         digitalWrite(ss, LOW);
         delay(10);
         SPI.transfer(SFTX);
         digitalWrite(ss, HIGH);
      }
     
      // Write slave select low to select slave device RF
      digitalWrite (ss, LOW);
      delay(10);
      // Transfer all bytes
      SPI.transfer(header);
      delay(10);
      SPI.transfer(address);
      SPI.transfer(red);
      SPI.transfer(green);
      SPI.transfer(blue);
      SPI.transfer(white);
      SPI.transfer(sleep);
      SPI.transfer(func);
      // Write slave pin high again to select slave
      digitalWrite (ss, HIGH);

      // Write STX command strobe
      digitalWrite(ss, LOW);
      delay(10);
      SPI.transfer(STX);
      digitalWrite(ss, HIGH);
    }

    void wakeUp()
    {
      // issue sidle command
      digitalWrite(ss, LOW);
      delay(10);
      SPI.transfer(SIDLE);
      digitalWrite(ss, HIGH);

      // read number of bytes
      digitalWrite(ss, LOW);
      delay(10);
      statusbyte = SPI.transfer(SNOP);
      digitalWrite(ss, HIGH);
     
      Serial.print("\nstatus before STX = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");

      // check number of bytes and flush if it is more than 0
      if ((statusbyte & 00001111) > 0){
        digitalWrite(ss, LOW);
        delay(10);
        SPI.transfer(SFTX);
        digitalWrite(ss, HIGH);
      }
     
      digitalWrite(ss, LOW);
      delay(10);
      statusbyte = SPI.transfer(SNOP);
      digitalWrite(ss, HIGH);
      Serial.print("\nstatus after possible SFTX = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");
     
      // Write slave select low to select slave device RF
      digitalWrite (ss, LOW);
      delay(10);
      // Transfer all bytes
      SPI.transfer(burstheader);
      //delay(10);
      SPI.transfer(0x95);
      //delay(10);
      SPI.transfer(0x00);
      //delay(10);
      SPI.transfer(0x00);
      //delay(10);
      SPI.transfer(0x00);
      //delay(10);
      SPI.transfer(0x00);
      //delay(10);
      SPI.transfer(0x00);
      //delay(10);
      SPI.transfer(0xAF);
      //delay(10);
      // Write slave pin high again to deselect slave
      digitalWrite (ss, HIGH);
     
      // DEBUG
      digitalWrite(ss, LOW);
      delay(10);
      statusbyte = SPI.transfer(SNOP);
      digitalWrite(ss, HIGH);
      Serial.print("\nstatus in FIFO = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");

      // Write STX command strobe
      digitalWrite(ss, LOW);
      delay(10);
      SPI.transfer(STX);
      digitalWrite(ss, HIGH);

      // DEBUG read bytes in FIFO
      digitalWrite(ss, LOW);
      delay(10);
      statusbyte = SPI.transfer(SNOP);
      digitalWrite(ss, HIGH);
      Serial.print("\nstatus after STX = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n--------------------------------\n");
    }

    // change the RF mode to transmit high gain by adjusting the PA_EN and LNA_EN
    // void TX_HGM()
    // {
    //   digitalWrite(HGM, HIGH);
    //   digitalWrite(PA_EN, HIGH);  
    //   digitalWrite(LNA_EN, LOW);
    // }


    void sendRegisters()
    {
      // Write slave select low to select slave device RF
      digitalWrite (ss, LOW);
      //delay(10);
      while (digitalRead(MISO)){};          // Wait untill MISO goes low
     
      // Transfer all bytes
      SPI.transfer(configheader);
      delay(10);
      SPI.transfer(0x29);            // 0x00 IOCFG2
      SPI.transfer(0x2E);            // 0x01 IOCFG1
      SPI.transfer(0x06);            // 0x02 IOCFG0
      SPI.transfer(0x47);            // 0x03 FIFOTHR changed from 0x4D
      SPI.transfer(0xD3);            // 0x04 SYNC1
      SPI.transfer(0x91);            // 0x05 SYNC0
      SPI.transfer(0x07);            // 0x06 PKTLEN       
      SPI.transfer(0x04);            // 0x07 PKTCTRL1
      SPI.transfer(0x04);            // 0x08 PKTCTRL0
      SPI.transfer(0x00);            // 0x09 ADDR
      SPI.transfer(0x00);            // 0x0A CHANNR
      SPI.transfer(0x0C);            // 0x0B FSCTRL1
      SPI.transfer(0x00);            // 0x0C FSCTRL0
      SPI.transfer(0x21);            // 0x0D FREQ2
      SPI.transfer(0x62);            // 0x0E FREQ1
      SPI.transfer(0x76);            // 0x0F FREQ0
      SPI.transfer(0x2D);            // 0x10 MDMCFG4
      SPI.transfer(0x3B);            // 0x11 MDMCFG3
      SPI.transfer(0x13);            // 0x12 MDMCFG2
      SPI.transfer(0x22);            // 0x13 MDMCFG1
      SPI.transfer(0xF8);            // 0x14 MDMCFG0
      SPI.transfer(0x62);            // 0x15 DEVIATN
      SPI.transfer(0x07);            // 0x16 MCSM2
      SPI.transfer(0x30);            // 0x17 MCSM1
      SPI.transfer(0x18);            // 0x18 MCSM0
      SPI.transfer(0x1D);            // 0x19 FOCCFG
      SPI.transfer(0x1C);            // 0x1A BSCFG
      SPI.transfer(0xC7);            // 0x1B AGCTRL2
      SPI.transfer(0x00);            // 0x1C AGCTRL1
      SPI.transfer(0xB0);            // 0x1D AGCTRL0
      SPI.transfer(0x87);            // 0x1E WOREVT1
      SPI.transfer(0x6B);            // 0x1F WOREVT0
      SPI.transfer(0xFB);            // 0x20 WORCRTRL
      SPI.transfer(0xB6);            // 0x21 FREND1
      SPI.transfer(0x10);            // 0x22 FREND0
      SPI.transfer(0xEA);            // 0x23 FSCAL3
      SPI.transfer(0x2A);            // 0x24 FSCAL2
      SPI.transfer(0x00);            // 0x25 FSCAL1
      SPI.transfer(0x1F);            // 0x26 FSCAL0
      SPI.transfer(0x41);            // 0x27 RCCTRL1
      SPI.transfer(0x00);            // 0x28 RCCTRL0
      SPI.transfer(0x59);            // 0x29 FSTEST
      SPI.transfer(0x7F);            // 0x2A PTEST
      SPI.transfer(0x3F);            // 0x2B AGCTEST
      SPI.transfer(0x88);            // 0x2C TEST2
      SPI.transfer(0x31);            // 0x2D TEST1
      SPI.transfer(0x09);            // 0x2E TEST0

      // Write slave pin high again to select slave
      digitalWrite (ss, HIGH);

      // DEBUG
      digitalWrite(ss, LOW);
      // delay(10);
      while (digitalRead(MISO)){};
      statusbyte1 = SPI.transfer(readheader);    // First it reads the status byte p30
      // delay(10);  
      compare2 = SPI.transfer(0);               // Then the register
      digitalWrite(SS, HIGH);
     
      // DEBUG
     // Serial.print("status after send registers = ");
     // Serial.print(statusbyte, HEX);
     // Serial.print("\n");  
      Serial.print("status readheader = ");
      Serial.print(statusbyte1, HEX);
      Serial.print("\nfirst register = ");
      Serial.print(compare2, HEX);
      Serial.print("\n\n");
    }

    However. For some reason when doing something as random as changing delays, the RF didn't return the right values for the set registers anymore (as I keep checking the registers were send properly in the setregister()). I changed the delays back but ever since it seems as if the SPI connection isn t working anymore.As I dont have that much understanding of the hardware, can someone please give me some pointers about how to handle this.

    Kind regards,

    Imara

  • Still having the same problem. Is there anything with a non-volatile state machine I need to keep in mind?? I dont know at all what im doing wrong here... Anyone please help?!

  • Well, after driving the cc1100 CS low, maybe it's a good idea to wait for SO line to go low, indicating the chip is ready for SPI exchange.

  • Thanks for your reply. Although I knew this was obligatory, I thought I could work around it by using long enough delays. Also, using an Arduino I found it difficult to wait for the SO to go low, because sometimes after the manual in software reset, the SO would never go low. I tried to apply it in my setup  function. Is this the way to go?

    void setup()
    {
      Serial.begin(115200);      // Set the baud rate for the monitor
      Serial.println("setup\n");

      // Set outputs
      pinMode (ss, OUTPUT);                // Declare the slave as an output
      SPI.begin();                         // Sets the inputs and outputs, pulling SCK and MOSI low and SS high
      delay(10);

      // initialize SPI:
      SPI.setBitOrder(MSBFIRST);           // Set the mode according to the RF slave (most significant bit first)
      SPI.setDataMode(SPI_MODE0);          // Base value clock is 0, data captured on rising edge (CPOL = 0, CHPA = 0)
      SPI.setClockDivider(SPI_CLOCK_DIV16); // 4 is default, should be 4, minimum chosen  according to freq board

      //Manual initialization power-on reset
      // strobe CSn LOW/HIGH
      digitalWrite(SCK, HIGH);            // later on add reset
      digitalWrite(MOSI, LOW);

      //digitalWrite(ss, LOW);
      //digitalWrite(ss, HIGH);
      // hold CSn high for at least 40 microseconds to pulling it low(the first time)
      digitalWrite(ss, LOW);
      delayMicroseconds(10);
      digitalWrite(ss, HIGH);
      delayMicroseconds(40);
      // Pull CSn low and wait for SO to go low (CHIP_RDYn)
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
        //while((statusbyte = SPI.transfer(SNOP)) >> 7){
        //Serial.println((statusbyte = SPI.transfer(SNOP)), BIN);
        //Serial.println((statusbyte >> 7), BIN);
          Serial.println("aaaa");
      };
      // issue the SRES strobe on the SI line (takes a long time, so wait a long delay
      SPI.transfer(SRES);
      //delayMicroseconds(1000);
      //while((statusbyte = SPI.transfer(SNOP)) >> 7){
      while(digitalRead(MISO)){
        Serial.println("reset");
      };
      //SPI.transfer(SIDLE);    // Set the RF in IDLE state
      //delayMicroseconds(headerdelay);
      digitalWrite(ss, HIGH);
      Serial.println("uit de reset");


      // DEBUG
      Serial.print("status after pulling CSn low = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");  

      // send register settings
      sendRegisters();

      // wake up the wristband - send a couple of times because the wristband listens for wake up on intervals
      for (i = 0; i < timeswakeup; i++)
      {
        wakeUp();
      }
    }

  • Ok i'm just going to rephrase my question as I am still in need of a lot of help. I found out why the registers weren't returning properly, although this was a dumb mistake. The arduino that I used as a MCU powered the digital pins with 5V instead of a proper 3.3V. I have now put a voltage divider in between using 3,3K and1,8K Ohm. Is this a proper way to steer the EM? Also, I believe that all this messing around at 5V has damaged the chip internally. Is there any way I can properly test this to make sure it's not a hardware issue?

    Also, I am not a hundred procent sure that I am waiting untill the SO line goes low after selecting a slave. Can anyone comment on that?

    Another question. I am not sure what the proper order of sending data is. I now have a SIDLE strobe, an SCAL, followed by an SFSTXON, then sending data to the TX fifo (although it seems as if no data is send) and then issueing an STX strobe and a SFTX.

    So i've managed to power the digital pins with a maximum of 3.4V, but is this enough using a voltage divider or do I need to take in mind the current?

    This is my code:

    /*   
     *   SPI communication with the RF module for Dutchband
     *   Initial prototype, needs further communication with DMX
     *   By Imara Speek
     */

    // inslude the SPI library:
    #include <SPI.h>


    /* SPI configution for slave RF device (arduino is Master) when including SPI.h
     * const int MOSI = 11;  // Master Output, slave input. Serial In RF  
     * const int MISO = 12;  // Master input, slave output, Serial Out RF
     * const int SCK = 13;   // Serial clock
     */
    const int ss = 10;       // Slave select the RF module

    // Current bytes for debugging
    byte red = 0x00;  
    byte green = 0x00;
    byte blue = 0x00;
    byte white = 0x00;
    byte sleep = 0x00;
    byte func = 0x00;
    byte vol = 0x0F;

    // Debugging
    byte statusbyte = 0x00;
    byte statusbyte1 = 0x00;
    byte statusbyte2 = 0x00;
    byte compare1 = 0x00;
    byte compare2 = 0x00;

    // Actual header to use
    byte configheader = 0x40;    // 01000000 to burst write to address 0x00, or config addresses
    byte readheader = 0x80;      // read slave input at address 10000000
    byte burstheader = 0x7F;     // header for transmit burst access

    byte address = 0x95;         // standard address necessary

    // Command strobes
    byte STX = 0x35;            // 00110101 STX command strobe to initiate TX mode
    byte SFTX = 0x3B;           // Flush the TX FIFO
    byte SFRX = 0x3A;           // Flush the RX FIFO
    byte SIDLE = 0x36;          // Set into idle state
    byte SNOP = 0x3D;           // SNOP to check status byte
    byte SRES = 0x30;           // RESET
    byte SFSTXON = 0x31;        // turn into TX state and calibrate
    byte SCAL = 0x33;           // calibrate frequency

    // set delays in microseconds
    const int slavedelay = 500;      // Dont go any lower than 500 microseconds!
    const int headerdelay = 500;     // Dont go any lower than 350 MicroSeconds
    const int datadelay = 1;         // A minimum delay because clock falls and rises in nanoseconds

    // variables
    int i;
    int timeswakeup = 33;            // Still some insecurity, should be listening for a minute

    void setup()
    {
      Serial.begin(115200);      // Set the baud rate for the monitor
      Serial.println("setup\n");

      // Set outputs
      pinMode (ss, OUTPUT);                // Declare the slave as an output
      SPI.begin();                         // Sets the inputs and outputs, pulling SCK and MOSI low and SS high
      delay(10);

      // initialize SPI:
      SPI.setBitOrder(MSBFIRST);           // Set the mode according to the RF slave (most significant bit first)
      SPI.setDataMode(SPI_MODE0);          // Base value clock is 0, data captured on rising edge (CPOL = 0, CHPA = 0)
      SPI.setClockDivider(SPI_CLOCK_DIV16); // 4 is default, should be 4, minimum chosen  according to freq board

      //Manual initialization power-on reset
      // strobe CSn LOW/HIGH
      digitalWrite(SCK, HIGH);            // later on add reset
      digitalWrite(MOSI, LOW);

      //digitalWrite(ss, LOW);
      //digitalWrite(ss, HIGH);
      // hold CSn high for at least 40 microseconds to pulling it low(the first time)
      digitalWrite(ss, LOW);
      delayMicroseconds(10);
      digitalWrite(ss, HIGH);
      delayMicroseconds(40);
      // Pull CSn low and wait for SO to go low (CHIP_RDYn)
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
        //while((statusbyte = SPI.transfer(SNOP)) >> 7){
        //Serial.println((statusbyte = SPI.transfer(SNOP)), BIN);
        //Serial.println((statusbyte >> 7), BIN);
        Serial.println("aaaa");
      };
      // issue the SRES strobe on the SI line (takes a long time, so wait a long delay
      SPI.transfer(SRES);
      //delayMicroseconds(1000);
      //while((statusbyte = SPI.transfer(SNOP)) >> 7){
      while(digitalRead(MISO)){
        Serial.println("reset");
      };
      //SPI.transfer(SIDLE);    // Set the RF in IDLE state
      //delayMicroseconds(headerdelay);
      statusbyte = SPI.transfer(SNOP);
      while(digitalRead(MISO)){
        Serial.println("empty FIFO");
      };
      SPI.transfer(SFTX);
      delayMicroseconds(headerdelay);
      SPI.transfer(SCAL);
      delayMicroseconds(headerdelay);
      digitalWrite(ss, HIGH);

      // DEBUG
      Serial.print("status after reset = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");  

      // send register settings
      sendRegisters();

      // wake up the wristband - send a couple of times because the wristband listens for wake up on intervals
      for (i = 0; i < timeswakeup; i++)
      {
        wakeUp();
      }
    }

    void loop()
    {
      // TODO write recognition of DMX signal

      // Send red strobe
      sendData(burstheader, address, vol, green, blue, white, sleep, func);
     delay(100);
      //delayMicroseconds(500);
      // send white strobe
      //sendData(burstheader, address, 0, 0, 0, 0, 0, 0x33);
      //delay(1000);
      //delayMicroseconds(500);
      // send Blue
      sendData(burstheader, address, red, green, vol, white, sleep, func);
      delay(100);
      //delayMicroseconds(500);
    }

    void sendData(byte header,byte address, byte red, byte green, byte blue, byte white, byte sleep, byte func)
    {
      // issue sidle command
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      SPI.transfer(SIDLE);
      delayMicroseconds(headerdelay);
      // check number of bytes and flush if it is more than 0
      //if ((SPI.transfer(SNOP) & 00001111) != 0){
      SPI.transfer(SFSTXON);
      //}
      digitalWrite(ss, HIGH);

      // Write slave select low to select slave device RF
      digitalWrite (ss, LOW);
      while(digitalRead(MISO)){
      }
      // Transfer all bytes
      SPI.transfer(header);
      delayMicroseconds(headerdelay);
      SPI.transfer(address);
      delayMicroseconds(datadelay);
      SPI.transfer(red);
      delayMicroseconds(datadelay);
      SPI.transfer(green);
      delayMicroseconds(datadelay);
      SPI.transfer(blue);
      delayMicroseconds(datadelay);
      SPI.transfer(white);
      delayMicroseconds(datadelay);
      SPI.transfer(sleep);
      delayMicroseconds(datadelay);
      SPI.transfer(func);
      delayMicroseconds(datadelay);
      // Write slave pin high again to select slave
      digitalWrite (ss, HIGH);

      // Write STX command strobe
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      SPI.transfer(STX);
      delayMicroseconds(headerdelay);
      //if ((SPI.transfer(SNOP) & 00001111) != 0){
      SPI.transfer(SFTX);
      //}
      digitalWrite(ss, HIGH);

      // check number of bytes and flush if it is more than 0
      Serial.print("\nsenddata");
    }

    void wakeUp()
    {
      // issue sidle command
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      SPI.transfer(SIDLE);
      delayMicroseconds(headerdelay);
      //statusbyte = SPI.transfer(SNOP);
      //delayMicroseconds(headerdelay);
      digitalWrite(ss, HIGH);

      // check number of bytes and flush if it is more than 0
      //if ((statusbyte & 00001111) != 0){
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      };
      SPI.transfer(SFTX);
      delayMicroseconds(headerdelay);
      digitalWrite(ss, HIGH);
      //}

      /*
      digitalWrite(ss, LOW);
       while(digitalRead(MISO)){}
       //statusbyte = SPI.transfer(SNOP);
       delayMicroseconds(headerdelay);
       digitalWrite(ss, HIGH);
       Serial.print("\nstatus after possible SFTX = ");
       Serial.print(statusbyte, HEX);
       Serial.print("\n");
       */

      // Write slave select low to select slave device RF
      digitalWrite (ss, LOW);
      while(digitalRead(MISO)){
      }
      // Transfer all bytes
      SPI.transfer(burstheader);
      delayMicroseconds(headerdelay);
      SPI.transfer(0x95);
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);
      delayMicroseconds(datadelay);
      SPI.transfer(0xAF);
      delayMicroseconds(datadelay);
      statusbyte = SPI.transfer(0x00);
      delayMicroseconds(datadelay);
      // Write slave pin high again to deselect slave
      digitalWrite (ss, HIGH);

      Serial.print("\nstatus during sending to TX FIFO = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");

      // DEBUG
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      statusbyte = SPI.transfer(SNOP);
      delayMicroseconds(headerdelay);
      digitalWrite(ss, HIGH);
      Serial.print("\nstatus in FIFO = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n");

      // Write STX command strobe
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      SPI.transfer(STX);
      //delayMicroseconds(headerdelay);
      //statusbyte = SPI.transfer(SNOP);
      delayMicroseconds(headerdelay);
      digitalWrite(ss, HIGH);

      // check number of bytes and flush if it is more than 0
      //if ((statusbyte & 00001111) != 0){
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      SPI.transfer(SFTX);
      delayMicroseconds(headerdelay);
      digitalWrite(ss, HIGH);
      //}


      // DEBUG read bytes in FIFO
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      statusbyte = SPI.transfer(SNOP);
      digitalWrite(ss, HIGH);
      Serial.print("\nstatus after STX and SFTX = ");
      Serial.print(statusbyte, HEX);
      Serial.print("\n--------------------------------\n");

    }

    void sendRegisters()
    {
      // Write slave select low to select slave device RF
      digitalWrite (ss, LOW);
      while(digitalRead(MISO)){
      }

      // Transfer all bytes
      SPI.transfer(configheader);
      delayMicroseconds(headerdelay);
      SPI.transfer(0x29);            // 0x00 IOCFG2
      delayMicroseconds(datadelay);
      SPI.transfer(0x2E);            // 0x01 IOCFG1
      delayMicroseconds(datadelay);
      SPI.transfer(0x06);            // 0x02 IOCFG0
      delayMicroseconds(datadelay);
      SPI.transfer(0x47);            // 0x03 FIFOTHR changed from 0x4D
      delayMicroseconds(datadelay);
      SPI.transfer(0xD3);            // 0x04 SYNC1
      delayMicroseconds(datadelay);
      SPI.transfer(0x91);            // 0x05 SYNC0
      delayMicroseconds(datadelay);
      SPI.transfer(0x07);            // 0x06 PKTLEN  
      delayMicroseconds(datadelay);  
      SPI.transfer(0x04);            // 0x07 PKTCTRL1
      delayMicroseconds(datadelay);
      SPI.transfer(0x04);            // 0x08 PKTCTRL0
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);            // 0x09 ADDR
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);            // 0x0A CHANNR
      delayMicroseconds(datadelay);
      SPI.transfer(0x0C);            // 0x0B FSCTRL1
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);            // 0x0C FSCTRL0
      delayMicroseconds(datadelay);
      SPI.transfer(0x20);            // 0x0D FREQ2 0x21 for old transeiver (26Mhz), new are 26Mhz
      delayMicroseconds(datadelay);
      SPI.transfer(0x25);            // 0x0E FREQ1 0x62 for old tranceiver (26Mhz), new are 0x25
      delayMicroseconds(datadelay);
      SPI.transfer(0xED);            // 0x0F FREQ0, 0x76 for old, new is 0xED
      delayMicroseconds(datadelay);
      SPI.transfer(0x8D);            // 0x10 MDMCFG4 0x2D
      delayMicroseconds(datadelay);
      SPI.transfer(0x2F);            // 0x11 MDMCFG3 0x3B
      delayMicroseconds(datadelay);
      SPI.transfer(0x13);            // 0x12 MDMCFG2
      delayMicroseconds(datadelay);
      SPI.transfer(0x22);            // 0x13 MDMCFG1
      delayMicroseconds(datadelay);
      SPI.transfer(0xE5);            // 0x14 MDMCFG0, 0xFB
      delayMicroseconds(datadelay);
      SPI.transfer(0x67);            // 0x15 DEVIATN, 0x62
      delayMicroseconds(datadelay);
      SPI.transfer(0x07);            // 0x16 MCSM2
      delayMicroseconds(datadelay);
      SPI.transfer(0x30);            // 0x17 MCSM1
      delayMicroseconds(datadelay);
      SPI.transfer(0x18);            // 0x18 MCSM0
      delayMicroseconds(datadelay);
      SPI.transfer(0x1D);            // 0x19 FOCCFG
      delayMicroseconds(datadelay);
      SPI.transfer(0x1C);            // 0x1A BSCFG
      delayMicroseconds(datadelay);
      SPI.transfer(0xC7);            // 0x1B AGCTRL2
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);            // 0x1C AGCTRL1
      delayMicroseconds(datadelay);
      SPI.transfer(0xB0);            // 0x1D AGCTRL0
      delayMicroseconds(datadelay);
      SPI.transfer(0x87);            // 0x1E WOREVT1
      delayMicroseconds(datadelay);
      SPI.transfer(0x6B);            // 0x1F WOREVT0
      delayMicroseconds(datadelay);
      SPI.transfer(0xFB);            // 0x20 WORCRTRL
      delayMicroseconds(datadelay);
      SPI.transfer(0xB6);            // 0x21 FREND1
      delayMicroseconds(datadelay);
      SPI.transfer(0x10);            // 0x22 FREND0
      delayMicroseconds(datadelay);
      SPI.transfer(0xEA);            // 0x23 FSCAL3
      delayMicroseconds(datadelay);
      SPI.transfer(0x2A);            // 0x24 FSCAL2
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);            // 0x25 FSCAL1
      delayMicroseconds(datadelay);
      SPI.transfer(0x1F);            // 0x26 FSCAL0
      delayMicroseconds(datadelay);
      SPI.transfer(0x41);            // 0x27 RCCTRL1
      delayMicroseconds(datadelay);
      SPI.transfer(0x00);            // 0x28 RCCTRL0
      delayMicroseconds(datadelay);
      SPI.transfer(0x59);            // 0x29 FSTEST
      delayMicroseconds(datadelay);
      SPI.transfer(0x7F);            // 0x2A PTEST
      delayMicroseconds(datadelay);
      SPI.transfer(0x3F);            // 0x2B AGCTEST
      delayMicroseconds(datadelay);
      SPI.transfer(0x81);            // 0x2C TEST2, 0x88
      delayMicroseconds(datadelay);
      SPI.transfer(0x35);            // 0x2D TEST1, 0x31
      delayMicroseconds(datadelay);
      SPI.transfer(0x09);            // 0x2E TEST0

      // Write slave pin high again to select slave
      digitalWrite (ss, HIGH);

      // DEBUG
      digitalWrite(ss, LOW);
      while(digitalRead(MISO)){
      }
      statusbyte1 = SPI.transfer(readheader);    // First it reads the status byte p30
      delayMicroseconds(headerdelay);
      compare2 = SPI.transfer(0);               // Then the register
      delayMicroseconds(headerdelay);
      digitalWrite(SS, HIGH);

      // DEBUG
      Serial.print("status readheader = ");
      Serial.print(statusbyte1, HEX);
      Serial.print("\nfirst register = ");
      Serial.print(compare2, HEX);
      Serial.print("\n\n");
    }

    I would appreciate all the help a lot!

    Imara

  • I solved the problem on my own, so this topic is no longer necessary. Thanks for the help.