sckaty 发表于 2014-9-24 17:15

cc2500读取的RSSI值为什么不会变?

cc2500寄存器的配置如下:
const RF_SETTINGS rfSettings = {
    0x07,   // FSCTRL1   Frequency synthesizer control.
    0x00,   // FSCTRL0   Frequency synthesizer control.
    0x5D,   // FREQ2   Frequency control word, high byte.
    0x93,   // FREQ1   Frequency control word, middle byte.
    0xB1,   // FREQ0   Frequency control word, low byte.
    0xC8,   // MDMCFG4   Modem configuration.
    0x93,   // MDMCFG3   Modem configuration.
    0x73,   // MDMCFG2   Modem configuration.
    0x22,   // MDMCFG1   Modem configuration.
    0xF8,   // MDMCFG0   Modem configuration.
    0x00,   // CHANNR    Channel number.
    0x01,   // DEVIATN   Modem deviation setting (when FSK modulation is enabled).
    0xB6,   // FREND1    Front end RX configuration.
    0x10,   // FREND0    Front end RX configuration.
    0x00,   // MCSM1   Main Radio Control State Machine configuration.
    0x18,   // MCSM0   Main Radio Control State Machine configuration.
    0x1D,   // FOCCFG    Frequency Offset Compensation Configuration.
    0x1C,   // BSCFG   Bit synchronization Configuration.
    0xC7,   // AGCCTRL2AGC control.
    0x00,   // AGCCTRL1AGC control.
    0xB0,   // AGCCTRL0AGC control.
    0xA9,   // FSCAL3    Frequency synthesizer calibration.
    0x0A,   // FSCAL2    Frequency synthesizer calibration.
    0x00,   // FSCAL1    Frequency synthesizer calibration.
    0x11,   // FSCAL0    Frequency synthesizer calibration.
    0x59,   // FSTEST    Frequency synthesizer calibration.
    0x88,   // TEST2   Various test settings.
    0x31,   // TEST1   Various test settings.
    0x0B,   // TEST0   Various test settings.
    0x07,   // FIFOTHR   RXFIFO and TXFIFO thresholds.
    0x29,   // IOCFG2    GDO2 output pin configuration.
    0x06,   // IOCFG0D   GDO0 output pin configuration. Refer to SmartRF?Studio User Manual for detailed pseudo register explanation.
    0x04,   // PKTCTRL1Packet automation control.
    0x05,   // PKTCTRL0Packet automation control.
    0x00,   // ADDR      Device address.
    0xFF    // PKTLEN    Packet length.
};
接收数据的代码如下:
BOOL CC2500_ReceivePacket(u8 *rxBuffer, u8 length)
{
    u8 status;
    u8 packetLength;

    if (GDO0_detected== 0)
    {
      return FALSE;                               //没有收到数据,退出
    }

    GDO0_detected--;

    if ((CC2500_ReadStatus(RXBYTES) & BYTES_IN_RXFIFO))
        {
      packetLength = CC2500_ReadReg(RXFIFO);
      // Read data from RX FIFO and store in rxBuffer
      if (packetLength <= length)
      {
            CC2500_ReadBurstReg(RXFIFO, rxBuffer, packetLength);
      
            // Read the 2 appended status bytes (status = RSSI, status = LQI)
            CC2500_ReadBurstReg(RXFIFO, status, 2);
            RCV_RSSI = status;                           // <------这个值永远是0x02   
            rssi = CC2500_ReadReg(RSSI_IND);                // <------这个值永远是0x5F

            CC2500_SendCmd(SIDLE);
            // Flush RX FIFO
            CC2500_SendCmd(SFRX);
            CC2500_SendCmd(SRX);          //置为接收      
            // MSB of LQI is the CRC_OK bit
            return (status & CRC_OK);
      }
      else
      {
            CC2500_SendCmd(SIDLE);
            CC2500_SendCmd(SFRX);
            CC2500_SendCmd(SRX);            //置为接收      
            return FALSE;
      }
    }
    else
      return FALSE;
}
然后,我每次读出来的RSSI的值总是固定的,紧接着Data field的那个值永远是0x02,直接读RSSI寄存器,永远是0x5F,不管拿远拿近,或是换一块cc2500,值都不会变。

有谁能告诉我,这是怎么一回事??

sckaty 发表于 2014-9-24 22:06

有人碰到过类似的情况吗?我现在一点头绪都没有,高手们给点建议呀。。

sckaty 发表于 2014-9-25 10:27

好吧,找到原因了,CC2500_ReadBurstReg()这个函数的问题,读出来的第一个字节总是错的

pentral0311 发表于 2014-10-24 18:02

为你这种共享原因的精神点个赞
页: [1]
查看完整版本: cc2500读取的RSSI值为什么不会变?