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.

LBT + retries wiht CC1120 - Getting stuck in TxPacket (interrupt not firing)

Other Parts Discussed in Thread: CC1120

Hi,

I'm using the CC1120 to send fixed size packets of 20 bytes. I have tried to incorporate listen-before-talk, as well as up to 3 random backoff time retries for each packet. After a few dozen broadcasts, the GPIO0 interrupt signal stays low and I am constantly timing out.

Is there anything else I need to re-arm before trying to resend a packet, or any suggestions as where I might be going wrong? I have pasted in my code below.

void TxPacketRf(uint8_t* data)
{
    uint8_t rssi;
    uint8_t txBuffer[PKTLEN+1] = {0};
    bool complete = false;
    uint8_t retries = 3;
    
    packetCounter++;
    
    trxRfSpiInterfaceInit();
    
    txBuffer[0] = PKTLEN;
    for(uint8_t i = 1; i < PKTLEN+1; i++)
    {
        txBuffer[i] = *data++;
    }
    
    while((complete == false)&&(retries--))
    {
        //Write packet to tx fifo
        cc112xSpiWriteTxFifo(txBuffer,sizeof(txBuffer));
        
        //Listen-Before_Talk block from here
        // Strobe RX
        trxSpiCmdStrobe(CC112X_SRX);
        
        // Wait for RSSI to be valid
        do
        {
            cc112xSpiReadReg(CC112X_RSSI0, &rssi, 1);
        } while (!(rssi & 0x01));
        
        // Air is free, strobe TX to send packet
        trxSpiCmdStrobe(CC112X_STX);
        
        //generate a 10ms (+up to 5ms random) timeout value
        uint8_t timeout = 0;
        sd_rand_application_vector_get((uint8_t *)&timeout, 1);
        timeout = timeout%6;        //to get 0-5
        timeout+=10;                        //15 milliseconds
        timeout*=10;                        //150 * 100us = 15ms

        while((packetSemaphore != ISR_ACTION_REQUIRED)&&(timeout > 0))
        {
            nrf_delay_us(100);
            timeout--;
        }
        packetSemaphore = ISR_IDLE;
        
        if(timeout > 0)
        {
            //packet went
            complete = true;
            printf("rfsent\n\r");
        }
        else
        {
            printf("timed out\n\r");
        }
    }
}

Thanks

  • If I read MARCSTATE, I am finding a value of 17 (this is after my interrupt signal disappears), indicating RX_FIFO_ERR.
    Does this mean that my CC1120 is receiving packets broadcast from other transmitters around it (my system consists of a bunch of transmitters all sending unidirectional packets to s single receiver)?
    If so, I didn't even know my transmitter was listening. Can I make it not listen? Or does RX_FIFO_ERR relate to something else?
  • I sem to be reading some wierd values from MARCSTATE that don't tie up with the datasheet. 00011011, 10011000, 00000011.
    The 00000011 value ties up with BIAS_SETTLE_MC, but this is midway during operation, what could cause that?
  • Hi Arthur

    When using LBT you must make sure that the radio is in RX mode before sending a STX strobe. Since the radio must be in RX to be able to listen to the channel, there is always a chance that you will receive a packet. If this packet is not handled by the SW, you might end up in a FIFO error state.

    If you want to make sure that you are not receiving anything when listening to the channel, you can simply set the SYNC_THR to 0. This way you will never detect a sync word and hence nothing will be put in the RXFIFO.

    Remember to set the threshold back to a recommended value when you want to put the radio into RX mode to receive data.

    BR

    Siri

  • Thanks Siri,
    Can I just confirm that my code implementation does look like it is correct (putting the radio in RX mode for LBT/RSSI listen) in the code below? your answer solved the packet reception issue, but got me worried my LBT strategy may be wrong.
    Thanks

    //Write packet to tx fifo
    cc112xSpiWriteTxFifo(txBuffer,sizeof(txBuffer));

    //Listen-Before_Talk block from here
    // Strobe RX
    trxSpiCmdStrobe(CC112X_SRX);

    // Wait for RSSI to be valid
    do
    {
    cc112xSpiReadReg(CC112X_RSSI0, &rssi, 1);
    } while (!(rssi & 0x01));

    // Air is free, strobe TX to send packet
    trxSpiCmdStrobe(CC112X_STX);
  • Hi

    Your code is correct, but as I said in the previous post I would recommend setting the sync threshold to 0 to avoid the radio leaving RX mode due to packet reception. If you do not want to change the threshold your code must handle reception of any packets and make sure to strobe the radio back into RX mode after packet reception. If you receive a packet and go back to RX mode, you need to strobe STX over again.

    BR

    Siri

  • Thanks Siri,
    I tried to add the following in my radio init, but seem to always time out when transmitting packets. I guess I have a conflicting setting somewhere, will have more time to debug thoroughly tomorrow hopefully. This is how I tried to set up that register:

    uint8_t writeByte;
    cc112xSpiReadReg(CC112X_SYNC_CFG0, &writeByte, 1);
    writeByte &= 0xE0;
    cc112xSpiWriteReg(CC112X_SYNC_CFG0, &writeByte, 1); //sets sync word to zero - disables packet reception
  • I should have been programming CC1120X_SYNC_CFG1, not CC1120X_SYNC_CFG0.
    Seems to be working now.