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.

Rssi Value In CC1120 Acknowledge Packet

Hi all,

Can we read the rssi value in acknowledge packet ?It is possible? 


Best

  • For all received packets it's possible to find from the RSSI registers what the RSSI was. On the PHY layer C1120 doesn't know that the packet is ACK or something else.
  • Hi Ter,

    Firstly,thanks your answer. I'm getting the rssi value from acknowledge packet now but this value doesn't change that it seems as stable whenever the distance is increased between Receiver and Transmitter devices.

    My code is as below;

    cc112xSpiReadReg(CC112X_RSSI1,&rssi_readout,1);
    rssi = (int16)((int8)rssi_readout) - RssiOffset;

    At this point, i'm nearly getting the rss value as 32 ( I think that it is wrong value) in acknowledge packet from Transmitter device and getting the rss value as 237 in Receiver device. Why don't we see the rss values as equal? Do you have any idea about this problem?

    Best
  • First of all the RSSI should be a negative value.

    And yes, if the Tx and Rx side are equal the RSSI should be equal to (or within a dB or two)

    Is this your own hardware? If so, send a packet from board A and use SmartRF Studio to receive it and check the RSSI value. Same with board B. If the value is the same, is the RSSI read the same both for the main packet and the ack packet? Is the timing the same?
  • void sendBeacon(void) {
     
       
        // Initialize packet buffer of size PKTLEN + 1
        uint8 txBuffer[PKTLEN+1] = {0};
        
        packetCounterTX = 0;
    
        
        tx_registers();    
        
        // Connect ISR function to GPIO2
        ioPinIntRegister(&radioRxTxISR);
    
        // Interrupt on falling edge
        ioPinIntTypeSet(IO_PIN_FALLING_EDGE);
    
        // Clear ISR flag
        ioPinIntClear();
    
        // Enable interrupt
        ioPinIntEnable();
    
        // Calibrate radio according to errata
        manualCalibration();
        
        //trxSpiCmdStrobe(CC112X_SAFC); automatic frequency compensation   
          //do {   
        
          
         while(1){
        
        // Wait for button push
          
          //Continiously sent packets until button is pressed
          do{
            
            // Update packet counter
            packetCounterTX++;
            
            // Create a random packet with PKTLEN + 2 byte packet counter + n x random bytes
            createPacket(txBuffer);
            
            // Write packet to tx fifo
            cc112xSpiWriteTxFifo(txBuffer,sizeof(txBuffer));
            
            // Strobe TX to send packet
            trxSpiCmdStrobe(CC112X_STX);
            
            // Wait for interrupt that packet has been sent. 
            // (Assumes the GPIO connected to the radioRxTxISR function is set 
            // to GPIOx_CFG = 0x06)
            while(!packetSemaphore) {
              uint8 readByte;
              //Read datarate from registers
              cc112xSpiReadReg(CC112X_MARCSTATE, &readByte, 1);
              if(readByte);
            };
            
            // Clear semaphore flag
            packetSemaphore = ISR_IDLE;
    
            rssi = Read8BitRssi();
                  
            write_tx();
            
          }while(!SW_PUSH);
        
      }
      // Put radio to sleep and exit application
      //trxSpiCmdStrobe(CC112X_SPWD);  
    }
    
    
    uint8 Read8BitRssi(void){
     uint8 rssi2compl,rssiValid;
     uint8 rssiOffset = 102;
     int8 rssiConverted;
     //Read RSSI_VALID from RSSI0
     cc112xSpiReadReg(CC112X_RSSI0, &rssiValid, 1);
     // Check if the RSSI_VALID flag is set
     if(rssiValid & 0x01){
     // Read RSSI from MSB register
     cc112xSpiReadReg(CC112X_RSSI1, &rssi2compl, 1);
     rssiConverted = (int8)rssi2compl - rssiOffset;
     return rssiConverted;
     }
     // return 0 since new value is not valid
     return 0;
    }
    
    static void tx_registers(void) {
     
        uint8 writeByte;       
    
        registerConfig();
        //RX Gain
        writeByte = 0x04; cc112xSpiWriteReg(CC112X_CHAN_BW, &writeByte, 1);  // RX filter bandwidth 200kHz
        writeByte = 0x11; cc112xSpiWriteReg(CC112X_AGC_CFG3, &writeByte, 1); //adjust min gain 
        writeByte = 0x20; cc112xSpiWriteReg(CC112X_AGC_CFG2, &writeByte, 1); //0x20-->max gain 0xA0-->previous gain
        writeByte = 0x19; cc112xSpiWriteReg(CC112X_AGC_REF, &writeByte, 1);  //0x19
         
        //TX Power
        writeByte = 0x7F; cc112xSpiWriteReg(CC112X_PA_CFG2, &writeByte, 1);
        writeByte = 0x56; cc112xSpiWriteReg(CC112X_PA_CFG1, &writeByte, 1);
        writeByte = 0x7C; cc112xSpiWriteReg(CC112X_PA_CFG0, &writeByte, 1);
        
        // TXOFF_MODE = RX
        writeByte = 0x38; cc112xSpiWriteReg(CC112X_RFEND_CFG0, &writeByte, 1); 
        
        // RXOFF_MODE = RX
        writeByte = 0x3F; cc112xSpiWriteReg(CC112X_RFEND_CFG1, &writeByte, 1); 
        
        // Max packet length = 2
        writeByte = 0x02; cc112xSpiWriteReg(CC112X_PKT_LEN, &writeByte, 1);  //auto ack. paketi --> Length + Address of transmitter + Address of receiver     
          
    }
    Hi Ter,

    Yes, the hardware is our own design. I have done some the change after your last reply in our Rx and TX function and which was checked  at the SmartRF Studio.

    Now, we are receiving decreasing  rssi value when we increase the distance between  RX and TX devices but we aren't receiving rssi value in acknowledge response in TX device. ( Maybe, there is a  missing register  )

    I'm sharing the our  TX codes as attached. Why didn't we receive rss value in TX device? Could you examine rssi part in this code?

    Best

  • Hi Ter,

    Do you have any suggestion about last reply ?

    Best
  • Correct me if I'm wrong but it looks like you don't strobe Rx to listen for the ACK?
  • void sendBeacon(void) {
     
       
        // Initialize packet buffer of size PKTLEN + 1
        uint8 txBuffer[PKTLEN+1] = {0};
        uint8 rxBuffer[10] ;
        uint8 control = 1;
        
        packetCounterTX = 0;
       
        
        while(control){
        
        tx_registers();    
        
        // Connect ISR function to GPIO2
        ioPinIntRegister(&radioRxTxISR);
    
        // Interrupt on falling edge
        ioPinIntTypeSet(IO_PIN_FALLING_EDGE);
    
        // Clear ISR flag
        ioPinIntClear();
    
        // Enable interrupt
        ioPinIntEnable();
    
        // Calibrate radio according to errata
        manualCalibration();
        
        //trxSpiCmdStrobe(CC112X_SAFC); automatic frequency compensation   
          //do {   
        
          
        
        
        // Wait for button push
          
          //Continiously sent packets until button is pressed
          do{
            
            // Update packet counter
            packetCounterTX++;
            
            // Create a random packet with PKTLEN + 2 byte packet counter + n x random bytes
            createBeacon(txBuffer);
            
            // Write packet to tx fifo
            cc112xSpiWriteTxFifo(txBuffer,sizeof(txBuffer));
            
            // Strobe TX to send packet
            trxSpiCmdStrobe(CC112X_STX);
            
            // Wait for interrupt that packet has been sent. 
            // (Assumes the GPIO connected to the radioRxTxISR function is set 
            // to GPIOx_CFG = 0x06)
            while(!packetSemaphore) {
              uint8 readByte;
              //Read datarate from registers
              cc112xSpiReadReg(CC112X_MARCSTATE, &readByte, 1);
              if(readByte);
            };
            
            // Clear semaphore flag
             
           
            
            trxSpiCmdStrobe(CC112X_SRX);
                 
            Delay10msx(9);
             
            cc112xSpiReadRxFifo(rxBuffer, 8);     
         
            if( rxBuffer[2] == 0xBB)
                
                 {          
               
                rssi = Read8BitRssi();
                TEST_LED = 1;      
                write_rx();
                control = 0;
    
                 } 
            packetSemaphore = ISR_IDLE;
                
            
          }while(!SW_PUSH);
        
      }
      // Put radio to sleep and exit application
      //trxSpiCmdStrobe(CC112X_SPWD);  
    }
    
    
    void waitBeacon(void) {
        
      
        uint8 rxBuffer[128] = {0};
        uint8 rxBytes;
        uint8 txTest[3];
        uint8 control = 1;
        uint8 marcStatus;
        packetCounterRX = 0;
        control = 1;
        
        //The Ack. packet should be written to the TX FIFO before RX mode is being entered
        
        rx_registers();
        
        txTest[0] = 2;            // Length
        txTest[1] = 0xAA;         // Transmitter address
        txTest[2] = 0xBB;         // Adres onay�
        
        
        // Connect ISR function to GPIO2
        ioPinIntRegister(&radioRxTxISR);  //P4.4 GPIO2 
    
        // Interrupt on falling edge
        ioPinIntTypeSet(IO_PIN_FALLING_EDGE);
    
        // Clear ISR flag
        ioPinIntClear();
    
        // Enable interrupt
        ioPinIntEnable();
           
        manualCalibration();   //her seferinde gerek var m�? test edilmeli.
        
        
        cc112xSpiWriteTxFifo(txTest, sizeof(txTest));
    
                    
        // Set radio in RX      
        trxSpiCmdStrobe(CC112X_SRX); 
        
       
           
        while(control){
             
          
        
        // 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
                packetCounterRX++;
                
                for(uint8 i=0; i<rxBytes; i++)
                receivedData[i] = rxBuffer[i]; 
                
              }
            }
          }
          
          // Update LCD
          //updateLcd();
          
          
                if(receivedData[2] == 'N'){
                  
                  packetSemaphore = 0;
                  
                  rssi = Read8BitRssi();
                  
                  write_rx();
                  
                  
                  // Write packet to tx fifo
                  cc112xSpiWriteTxFifo(txTest, sizeof(txTest));
                  
                  // Strobe TX to send packet
                  trxSpiCmdStrobe(CC112X_STX);
                  
                  Delay10msx(9);
                  
                  // Wait for interrupt that packet has been sent. 
                  // (Assumes the GPIO connected to the radioRxTxISR function is set 
                  // to GPIOx_CFG = 0x06)
                  while(!packetSemaphore) {
                    uint8 readByte;
                    //Read datarate from registers
                    cc112xSpiReadReg(CC112X_MARCSTATE, &readByte, 1);
                    if(readByte);
                  };
                  
                  // Reset packet semaphore
                  packetSemaphore = ISR_IDLE;
                  
                  control = 0;
                  
                  //sendDeviceAddress();
                  //Flag2.BeaconWasTaken = 1;
                  //control = 0;
                           
          
          }
          
      
          
          // Set radio back in RX
          // trxSpiCmdStrobe(CC112X_SRX);
          
          
        trxSpiCmdStrobe(CC112X_SFRX);
    
        Delay10msx(10);
        
        trxSpiCmdStrobe(CC112X_SFTX);
    
        Delay10msx(10);
    
        trxSpiCmdStrobe(CC112X_SRES);
          
        }
      } 
      // Put radio to sleep and exit application
      //trxSpiCmdStrobe(CC112X_SPWD);
    }
    
    
    static void rx_registers(void) {
      
        uint8 writeByte;     
        
        registerConfig();
        
        //RX Gain
        writeByte = 0x04; cc112xSpiWriteReg(CC112X_CHAN_BW, &writeByte, 1); //RX filter bandwidth 200kHz
        writeByte = 0x11; cc112xSpiWriteReg(CC112X_AGC_CFG3, &writeByte, 1); //adjust min gain 
        writeByte = 0x20; cc112xSpiWriteReg(CC112X_AGC_CFG2, &writeByte, 1); //0x20-->max gain 0xA0-->previous gain
        writeByte = 0x19; cc112xSpiWriteReg(CC112X_AGC_REF, &writeByte, 1);  //0x19
        
        //TX Power
        writeByte = 0x7F; cc112xSpiWriteReg(CC112X_PA_CFG2, &writeByte, 1);
        writeByte = 0x56; cc112xSpiWriteReg(CC112X_PA_CFG1, &writeByte, 1);
        writeByte = 0x7C; cc112xSpiWriteReg(CC112X_PA_CFG0, &writeByte, 1);
          
        // LBT
        writeByte = 0x10; cc112xSpiWriteReg(CC112X_PKT_CFG2, &writeByte, 1); //Indicates clear channel when RSSI is below threshold and ETSI LBT requirements are met
        writeByte = 10; cc112xSpiWriteReg(CC112X_AGC_CS_THR, &writeByte, 1); //carrier sense threshold = CS threshold - RSSI offset = -92 - (-102) = 10
        
        // TXOFF_MODE = RX
        writeByte = 0x38; cc112xSpiWriteReg(CC112X_RFEND_CFG0, &writeByte, 1); 
        
        //RX Off mode=TX
        writeByte = 0x2E; cc112xSpiWriteReg(CC112X_RFEND_CFG1, &writeByte, 1);
        
    }
    
    /*******************************************************************************
    *   @fn         tx_registers
    *
    *   @brief      Transmitter'a �zel register ayarlar�. Ref: 1120 User Guide
    *
    *   @param      none
    *
    *   @return     none
    */
    static void tx_registers(void) {
     
        uint8 writeByte;       
    
        registerConfig();
        //RX Gain
        writeByte = 0x04; cc112xSpiWriteReg(CC112X_CHAN_BW, &writeByte, 1);  // RX filter bandwidth 200kHz
        writeByte = 0x11; cc112xSpiWriteReg(CC112X_AGC_CFG3, &writeByte, 1); //adjust min gain 
        writeByte = 0x20; cc112xSpiWriteReg(CC112X_AGC_CFG2, &writeByte, 1); //0x20-->max gain 0xA0-->previous gain
        writeByte = 0x19; cc112xSpiWriteReg(CC112X_AGC_REF, &writeByte, 1);  //0x19
         
        //TX Power
        writeByte = 0x7F; cc112xSpiWriteReg(CC112X_PA_CFG2, &writeByte, 1);
        writeByte = 0x56; cc112xSpiWriteReg(CC112X_PA_CFG1, &writeByte, 1);
        writeByte = 0x7C; cc112xSpiWriteReg(CC112X_PA_CFG0, &writeByte, 1);
        
        // TXOFF_MODE = RX
        writeByte = 0x38; cc112xSpiWriteReg(CC112X_RFEND_CFG0, &writeByte, 1); 
        
        // RXOFF_MODE = RX
        writeByte = 0x3F; cc112xSpiWriteReg(CC112X_RFEND_CFG1, &writeByte, 1); 
        
        // Max packet length = 2
        writeByte = 0x02; cc112xSpiWriteReg(CC112X_PKT_LEN, &writeByte, 1);  //auto ack. paketi --> Length + Address of transmitter + Address of receiver     
          
    }
    
    uint8 Read8BitRssi(void){
     uint8 rssi2compl,rssiValid;
     uint8 rssiOffset = 102;
     int8 rssiConverted;
     //Read RSSI_VALID from RSSI0
     cc112xSpiReadReg(CC112X_RSSI0, &rssiValid, 1);
     // Check if the RSSI_VALID flag is set
     if(rssiValid & 0x01){
     // Read RSSI from MSB register
     cc112xSpiReadReg(CC112X_RSSI1, &rssi2compl, 1);
     rssiConverted = (int8)rssi2compl - rssiOffset;
     return rssiConverted;
     }
     // return 0 since new value is not valid
     return 0;
    }
    

    Hi Ter,

    Great, i have added the strobe as you say in attached and we are getting rss value in acknowledge packet but it look like there is a problem.

    Normally, we are getting  200 rss value nearly at the  RX device but  who are getting  136 rss value at the TX device(ack packet).

    We are receiving decreasing  rssi value for RX device when we increase the distance between  RX and TX devices but acknowledge rss value doesn't change when  increase the distance.

    Maybe,  the pulse interval of acknowledge packet is less than normal TX. Do you have any idea about why doesn't change the value of this rss?  

    Best 

  • Do you know if you have actually received the ack packet? Receiving a ack packet is equal to receiving a normal packet. It could be that you read the last RSSI value or similar since it's not changing.