here’s how you should sequence the radio to bring it out of reset for reliable operation →
void RadioReset(void)
{
nRST_LO; nPD_LO; nSS_HI; SCK_LO;
DelayMicroSec(tPWR_RST); //1300usec min.
nPD_HI;
DelayMicroSec(tPDN_X13); //2000usec typ.
nRST_HI;
DelayMicroSec(tSPI_RDY); //1usec min.
nPD_HI;
DelayMicroSec(CRYSTAL_STARTUP); // ~Xmsec for crystal start to stable - idle
}
then you should probably perform basic radio initialization, here’s one example →
// RadioInit table - reg addr followed by init value, sequence is important
const BYTE code RadioInitTable[] =
{
0x20, 0x45, //REG_ANALOG_CTL
0x20, 0x44, //REG_ANALOG_CTL
0x2E, 0x80, //REG_PWR_CTL
0x26, 0xC0, //REG_VCO_CAL
0x33, 0x41, //REG_CLOCK_ENABLE
0x32, 0x41, //REG_CLOCK_MANUAL
0x24, 0x40, //REG_CRYSTAL_ADJ
0x06, 0x09, //REG_SERDES_CTL, EOF=1 (first missed correlation)
0x10, 0xFF, //REG_TX_VALID
0x23, 0x05, //REG_PA - PA=5
0x21, 0x02 //REG_CHANNEL = 2402MHz
};
void RadioInit(void)
{
BYTE i;
for(i=0;i<sizeof(RadioInitTable);i+=2) {
SpiWrite(RadioInitTable[i],RadioInitTable[i+1]);
}
}
then you can perform a manual RSSI conversion by doing something like this →
BYTE RadioGetRssi(void)
{
BYTE x=0;
SpiWrite((SPI_FRZ | 0x2F), 0x80); //REG_CARRIER_DETECT - set CDET to force radio to manually acquire rssi reading
SpiWrite((SPI_FRZ | 0x03), 0x90); //REG_CONTROL - put radio in receive mode - triggers rssi adc
DelayMicroSec(SYNTH_SETTLE); // wait for synth to settle
DelayMicroSec(RECEIVER_READY); // wait for receiver ready
DelayMicroSec(RSSI_ADC_CONVERSION); // wait for 5-bit rssi adc to complete
x = SpiRead((SPI_FRZ | 0x22)); //REG_RSSI - flush stale rssi reading
DelayMicroSec(RSSI_ADC_CONVERSION); // wait for 5-bit rssi adc to complete
x = SpiRead((SPI_FRZ | 0x22)); //REG_RSSI - get rssi reading
SpiWrite((SPI_FRZ | 0x2F), 0x00); //REG_CARRIER_DETECT - manually clear CDET
SpiWrite((SPI_FRZ | 0x03), 0x00); //REG_CONTROL - put radio in idle mode
return(x);
}
where →
#define SPI_FRZ 0x00
#define SYNTH_SETTLE 200 * 0.65 // 200usec
#define RECEIVER_READY 35 * 0.65 // 35usec
#define CRYSTAL_STARTUP 2100 * 0.65 // 2100usec
#define RSSI_ADC_CONVERSION 50 * 0.65 // 50usec
#define CRYSTAL_STARTUP 2100 * 0.65 // 2100usec
#define tPD 10 * 0.65 // 10usec
#define tPWR_RST 1300 * 0.65 // 1300usec
#define tPDN_X13 2000 * 0.65 // 2000usec
#define tSPI_RDY 1 * 0.65 // 1usec
// 0.65 is the implementation specific cal factor for DelayMicroSec();