RSSI read on CC2500

Hello everybody,

I want to read the RSSI register from a CC2500 transceiver (2.4 GHz, Texas instruments) like on a project I’ve found: http://tim.cexx.org/?paged=2

There is another similar project: http://cnx.org/content/m21599/latest/

And there is more info about RSSI from manufacturer: http://prochild.co.kr/board/files/tb_3/DN505%20RSSI%20Interpretation%20and%20Timing%20swra114a.pdf

Finally, there is the code:

#include "CC2500.h"

#define MOSI   11    // SPI master data out pin
#define MISO   12    // SPI master data in pin
#define SCK    13    // SPI clock pin
#define CS     10    // SPI slave select pin

CC2500 board(CS, SCK, MOSI, MISO);

int RSSI;

void setup()
{  
    // setup serial port
    Serial.begin(57600);
    Serial.println("Starting....");
    board.ConfigureBoard();    
}

void loop()
{
  
  for(;;)
  {
  unsigned char* rxdata; 
  //unsigned char* RSSI;
  //unsigned char ID = 0x00;
  //unsigned char PartID = 0x00;
  
  dump_rssi();
  }
}


void dump_rssi(void)
{
 int i;
 char rssi=0x00;
 for(i=0; i<256; i++)
 {
   board.sendCommand(CC2500_REG_CHANNR, i);
   board.sendStrobeCommand(CC2500_CMD_SRX); // enter Rx mode (not needed except to start autocal)
   
   rssi = MRFI_Rssi();
   //rssi = board.sendCommand(CC2500_REG_RSSI | 0xC0, 0xDB); //Especificar mejor comando
   //rssi = board.sendByte(0xDB);
   //rssi = MRFI_Rssi();
   //rssi = calc_rssi(rssi);
   
   
   board.sendStrobeCommand(CC2500_CMD_SIDLE); // enter IDLE mode (not needed except for autocal)
        
   delay(20);
   Serial.println("Channel:");
   Serial.print(i, DEC);
   Serial.print("Received Data. RSSI(dBm):");
   Serial.print(rssi, DEC);
   Serial.println("");
 }
}

//------------------------------------------------------------
//Functions from mrfi_radio.c
//------------------------------------------------------------



int8_t MRFI_Rssi(void)
{
  uint8_t regValue;

  /* Radio must be in RX state to measure rssi. */
  board.sendStrobeCommand(CC2500_CMD_SRX);

  /* Wait for the RSSI to be valid:
   * Just having the Radio ON is not enough to read
   * the correct RSSI value. The Radio must in RX mode for
   * a certain duration. This duration depends on
   * the baud rate and the received signal strength itself.
   */
  
  delay(1);          //Extra time to obtain a correct RSSI value

  /* Read the RSSI value */
  regValue = mrfiSpiReadReg(0x3D);

  /* convert and do offset compensation */
  return( Mrfi_CalculateRssi(regValue) );
}


/**************************************************************************************************
 * @fn          Mrfi_CalculateRssi
 *
 * @brief       Does binary to decimal conversiont and offset compensation.
 *
 * @param       none
 *
 * @return      RSSI value in units of dBm.
 **************************************************************************************************
 */
int8_t Mrfi_CalculateRssi(uint8_t rawValue)
{
  int16_t rssi;
  int16_t MRFI_RSSI_OFFSET = 70;

  /* The raw value is in 2's complement and in half db steps. Convert it to
   * decimal taking into account the offset value.
   */
  if(rawValue >= 128)
  {
    rssi = (int16_t)(rawValue - 256)/2 - MRFI_RSSI_OFFSET;
  }
  else
  {
    rssi = (rawValue/2) - MRFI_RSSI_OFFSET;
  }

  /* Restrict this value to least value can be held in an 8 bit signed int */
  if(rssi < -128)
  {
    rssi = -128;
  }

  return rssi;
}


uint8_t mrfiSpiReadReg(uint8_t addr)
{
  //MRFI_SPI_ASSERT(addr <= 0x3B);    /* invalid address *///poipoi
  //MRFI_SPI_ASSERT(addr <= 0x3D);    //poipoi
  
  /*
   *  The burst bit is set to allow access to read-only status registers.
   *  This does not affect normal register reads.
   */
  return( board.sendCommand(addr | 0xC0 | 0x34, 0xDB) );
}

My problem is that I always obtain the same value for RSSI, on all channels, and that is not possible. Maybe some of you can help me.

Thank you,
Enric.

Please, I need help. Someone has programmed it before?