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.

a question for cc1120_vchip_easy_link_rx2.c

Other Parts Discussed in Thread: CC1120

I have a question on cc1120 official example. According to the cc1120_vchip_easy_link_rx.c I find that the runRX is using ISR-like mode to read data from FIFO, and the code is presented as below.

This receive process includes a series of operation. Only after I have reset the packetSemaphore to ISR_IDLE, and reset CC112X_SRX, can I start the next receive.

So my question is ,if there is another packet transmission before my reset, can I receive this packet correctly? Will that packet be stored into RXFIFO automatically and wait for my read or just be simply discarded?

    // Wait for packet received interrupt
    if(packetSemaphore == ISR_ACTION_REQUIRED){

      // Read number of bytes in rx fifo
      cc112xSpiReadReg(CC112X_NUM_RXBYTES, &rxBytes, 1);

      // Check that we have bytes in fifo
      if(rxBytes != 0){

        // Read marcstate to check for RX FIFO error
        cc112xSpiReadReg(CC112X_MARCSTATE, &marcStatus, 1);

        // Mask out marcstate bits and check if we have a RX FIFO error
        if((marcStatus & 0x1F) == RX_FIFO_ERROR){

          // Flush RX Fifo
          trxSpiCmdStrobe(CC112X_SFRX);
        }
        else{

          // Read n bytes from rx fifo
          cc112xSpiReadRxFifo(rxBuffer, rxBytes);

          // Check CRC ok (CRC_OK: bit7 in second status byte)
          // This assumes status bytes are appended in RX_FIFO
          // (PKT_CFG1.APPEND_STATUS = 1.)
          // If CRC is disabled the CRC_OK field will read 1
          if(rxBuffer[rxBytes-1] & 0x80){

            // Update packet counter
            packetCounter++;

            /**************************************/
            UART_Printf(rxBuffer,rxBytes);
            /**************************************/

            halLedToggle(LED1);

          }
        }
      }
      // Reset packet semaphore
      packetSemaphore = ISR_IDLE;

      // Set radio back in RX
      trxSpiCmdStrobe(CC112X_SRX);

    }
  

  • Hi

    The setting in the EasyLink code sets the RXOFF_MODE to be IDLE. That means that after a packet is received the radio enters IDLE state and must manually be put into RX.

    To make the code really simple, the complete packet is read from the FIFO and processed before the radio is put into RX mode again. It is fully possible to set RXOFF_MODE = RX or put the radio back in RX mode manually before having read out the FIFO. The SW must then make sure the FIFO is read fast enough to make room for the next packet to avoid overflow.

    As long as the radio is in RX state and the FIFO is not full the radio will receive packets.

    BR

    Siri

  • Siri said:
    As long as the radio is in RX state and the FIFO is not full the radio will receive packets.

    Thank you, siri, but I cannot fully get your point.

    1) When I conduct cc112xSpiReadRxFifo(rxBuffer, rxBytes); will the RXOFF_MODE be automatically put into IDLE state? What is the moment the RXOFF_MODE is set IDLE, because there's no such setting in the codes I have given above. 

    2)Can radio receive packets when the RXOFF_MODE is in IDLE state? Can radio receive packets when is not in RX state? If not, where will the packets go?

  • 1) See figure 2 in http://www.ti.com/lit/ug/swru295e/swru295e.pdf Dependent on the value of RFEND_CFG1.RXOFF_MODE the radio will go to a given mode when you have received a packet. As Siri pointed out your settings is to go to IDLE after you have received a packet. This is a typical user case where the receiver is set up to give an interrupt when the packet is received. The MCU then read the FIFO and dependent on the protocol let the radio stay in IDLE or strobe SRX again.

    2) To receive a packet the radio has to be in Rx.

  • TER said:
    As Siri pointed out your settings is to go to IDLE after you have received a packet

    Thanks a lot TER, but there's still one thing I am not clear. Could you directly tell me that, in which sentence I set the radio to IDLE when I have received a packet? I cannot find this setting code in my given code above.

    BR,

    Young

  • Solved it. It is because I have configure through the RFEND_CFG1 to set that when I receive a good packet, the radio automatically reset to IDLE. set 0x3F to change to continuous RX mode. Theres' totally nothing to do with the codes I have given above.

    Thank TER and Siri.