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.

CC1101 SPI read always 0x0F

Other Parts Discussed in Thread: CC1101

Dear All,

I am using the CC1101 in a RKE application.  I am having some issues when reading SPI data from the device.  Basically I am trying to read data from a configuration register that was previously written.  After performing the SPI read all I recieve is 0x0F (the status byte), rather than the data stored at the given address.  The CC1101 is interfaced to a PIC microcontroller.  I was wondering if anybody has encountered this type of problem?

Thanks in advance for your help.

Dino

  • The status byte is always returned as the first byte on a read operation of the SPI port.  You must send additional dummy bytes to get the actual data from the register haver the read command and register address have been sent.  Note that the entire sequence is done with a single CS strobe otherwise the SPI state machine will be reset.

    Jim Noxon

  • Hi Jim,

    Thanks for the quick response.  I believe that I'm following the sequence you described, unless I'm missing something.  The read function I used is shown below.

    char CC1101_SPIReadReg(char addr)
    {
       char data;
       output_bit(UHF_ENABLE, 0);    //Enable CC1101
       while(input(SDI));                        //Wait for SDO to go low, indicating that the CC1101 is ready
       spi_write((addr&0x3F)|0x80);   //Send address - bit 6 low and bit 7 high to indicate a read single request
       if(spi_data_is_in())
          data = spi_read(0);                   //Send dummy byte
       output_bit(UHF_ENABLE, 1);    //Disable CC1101
       return data;
    }

    I have also verified that the read command and address is being sent with a scope.  If I monitor the SDO output from the CC1101 I can see the status byte after I issue the spi_write command, and after I send the dummy byte as well.

    Thanks.

    Regards,

    Dino

  • So what I see in your code is you toggle the CS line with every byte written.  As explained in section 10 of the CC1101 spec (http://focus.ti.com/lit/ds/symlink/cc1101.pdf), you must leave the CS line low for the entire communication or the communications state machine will be cancelled and must be restarted.  Thus I would suggest the output_bit(UHF_ENABLE, x) statements should be outside of this function so the CS line will remain low for the bytes following the byte with the address and r/w bit etc.  This way, you can call this function multiple times for each byte you wish to transfer and only modify the CS line when appropriate for the type of communication you are trying to accomplish.

    Jim Noxon

  • Thanks for looking at my code. Upon closer inspection I realised that I am not actually sending the dummy byte. As you mentioned, I am only sending one byte before toggling the CS line.  I have updated the code so that I am now sending the dummy byte after the read command before toggling the CS line.  This is in line with some of the TI software examples I have looked at.  I would expect to see the register contents after the dummy write, but I'm still only receiving the status byte (0x0F) in response.  Maybe my understanding is incorrect?

    char CC1101_SPIReadReg(char addr)
    {
       char status;
       char data;
       output_bit(UHF_ENABLE, 0);   //Enable CC1101
       while(input(SDI));                        //Wait for SDO to go low, indicating that the CC1101 is ready
       spi_write((addr&0x3F)|0x80);   //Send address - bit 6 must be low and bit 7 high to indicate a read single request
       if(spi_data_is_in())                     //Wait until data is ready
          status = spi_read();                 //Read status byte
       spi_write(0x00);                           //Send dummy byte to read register at "addr"
       if(spi_data_is_in())                     //Wait until data is ready
          data = spi_read();                    //Read register data
       output_bit(UHF_ENABLE, 1);   //Disable CC1101
       return data;
    }

    Regards,

    Dino

  • Make sure you clear your status byte being tested in the spi_data_is_in() call otherwise your second read of the SPI read register will provide the same result as the first.  Also, you should probably be using a while loop to test the spi_data_is_in() call (unless you implement it inside this function) as you want to make sure you wait for the data byte to be completely recieved before reading it.

    Other than that, all looks like it should work.

    Jim Noxon

  • Thanks Jim,

    I tried running the same code on another board (transmitter) which is the other half of the project and it worked without a problem.  This board uses a different PIC micro but the SPI core is identicle.  I also tried sending a TX strobe command and saw that the status byte changed accordingly to indicate that the transmitter is enabled.  I then tried sending the TX strobe on the original board and the status byte returned was 0x0F once again.  So it appears that I am always getting the same status byte returned regardless of the command I send.  Are you aware of any conditions that could cause this?  The device doesn't appear to be damaged, the voltage levels on the DCOUPL pin etc are as expected.

    I will still try your other suggestions.

    Dino

  • As a stab in the dark I tried solder reflowing the part even though it looked OK, and it came good! It must have been a soldering issue causing the problem.  I'm not sure why everything else seemed function.  Thanks a lot for your help Jim, it was much appreciated.  I hope I didn't wast too much of your time.

    Dino

  • This is not a total surprise.  However, it wasn't my first choice due to the belief we were getting at least something back from the radio.  Perhaps it was just a timing thing which caused the data line to flip at the 4th bit.

    Managing the ground connection under the radio has proven difficult for prototypes built when access to reflow ovens or proper BGA rework equipment doesn't exist.  Using hotplates, toaster ovens, and hot air guns all require a bit of artistic touch to get good solder connections on a regular basis.  Typically I build 4 to 5 prototypes at a time fully expecting 1 or 2 units to fail.  If I get some to work as expected, then I blame my lack of artistic capability in the assembly process.

    Just a note, this can also cause wide variations in range testing so my suggestion is to have at least one small run built on proper assembly equipment for range testing as this will probably be most like what to expect for the final product.

    Jim Noxon

  • sir , i have  implemented the logic of cc1101 register reading but after sending the dummy value im getting the value of the status byte only 

  • I was hoping someone could point me to where it says that the status byte is returned first in a read operation. I have seen in the datasheet that a status bit is returned concurrently with the read command, but not that it is the first byte returned.

    I ask because I am currently experiencing unexplainable behavior from the device, and want to make sure that I have the appropriate literature to understand if I am doing something incorrectly.

    Thanks,
    Gary

  • Hi Gary

    Page 31 of the data sheet:

    "

    10.1 Chip Status Byte

    When the header byte, data byte, or command

    strobe is sent on the SPI interface, the chip

    status byte is sent by the CC1101 on the SO pin

    "

    This is also showed in Figure 15 og page 30.

    Siri