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.

[参考译文] CC1101:RSSI LQI 读取值、但 CC1101可以正常通信

Guru**** 1127450 points
请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

https://e2e.ti.com/support/wireless-connectivity/sub-1-ghz-group/sub-1-ghz/f/sub-1-ghz-forum/1256909/cc1101-rssi-lqi-reads-value-but-cc1101-can-communicate-normally

器件型号:CC1101
主题中讨论的其他器件:测试2

大家好、

读取寄存器数据时、RSSI 和 LQI 始终处于仅在未接收信号的特定时间发生变化的值。 因此很难获得 RSSI 和 LQI 值、从而导致无法知道天线是什么样子。 客户尝试直接读取相应的寄存器0x33 [0xF3] 0x34[0xF4]、也采用开放的寄存器设置0x07:PKTCTRL1读取0x05、缓冲区后两位。  

  1. 是否需要在特定时间点(例如接收数据包后)读取 RSSI 和 LQI 值?
  2. 是否需要配置任何特定的寄存器或设置来正确读取 RSSI 和 LQI?
  3. 以下硬件和天线配置是否会影响 RSSI 和 LQI 读取?
  4. 是否有任何可能影响 RSSI 和 LQI 读取的特定信号条件或环境因素?  

设置如下:

typedef struct
{
    uint8_t iocfg0;   // GDO0 Output Pin Configuration
    uint8_t fifothr;  // RX FIFO and TX FIFO Thresholds
    uint8_t sync1;    // Sync Word, High Byte
    uint8_t sync0;    // Sync Word, Low Byte
    uint8_t pktlen;   // Packet Length
    uint8_t pktctrl0; // Packet Automation Control
    uint8_t fsctrl1;  // Frequency Synthesizer Control
    uint8_t freq2;    // Frequency Control Word, High Byte
    uint8_t freq1;    // Frequency Control Word, Middle Byte
    uint8_t freq0;    // Frequency Control Word, Low Byte
    uint8_t mdmcfg4;  // Modem Configuration
    uint8_t mdmcfg3;  // Modem Configuration
    uint8_t mdmcfg2;  // Modem Configuration
    uint8_t mdmcfg1;  // Modem Configuration
    uint8_t deviatn;  // Modem Deviation Setting
    uint8_t mcsm0;    // Main Radio Control State Machine Configuration
    uint8_t foccfg;   // Frequency Offset Compensation Configuration
    uint8_t agcctrl2; // AGC Control
    uint8_t agcctrl1; // AGC Control
    uint8_t worctrl;  // Wake On Radio Control
    uint8_t fscal3;   // Frequency Synthesizer Calibration
    uint8_t fscal2;   // Frequency Synthesizer Calibration
    uint8_t fscal1;   // Frequency Synthesizer Calibration
    uint8_t fscal0;   // Frequency Synthesizer Calibration
    uint8_t test2;    // Various Test Settings
    uint8_t test1;    // Various Test Settings
    uint8_t test0;    // Various Test Settings
} RF_SETTINGS;

static RF_SETTINGS E07x_InitSetting = {
    0x06, // IOCFG0        GDO0 Output Pin Configuration
    0x47, // FIFOTHR       RX FIFO and TX FIFO Thresholds
    0x7A, // SYNC1         Sync Word, High Byte
    0x0E, // SYNC0         Sync Word, Low Byte
    0x14, // PKTLEN        Packet Length
    0x05, // PKTCTRL0      Packet Automation Control
    0x06, // FSCTRL1       Frequency Synthesizer Control
    0x10, // FREQ2         Frequency Control Word, High Byte
    0xB1, // FREQ1         Frequency Control Word, Middle Byte
    0x3B, // FREQ0         Frequency Control Word, Low Byte
    0xF5, // MDMCFG4       Modem Configuration
    0x83, // MDMCFG3       Modem Configuration
    0x13, // MDMCFG2       Modem Configuration
    0x02, // MDMCFG1       Modem Configuration
    0x31, // DEVIATN       Modem Deviation Setting
    0x18, // MCSM0         Main Radio Control State Machine Configuration
    0x16, // FOCCFG        Frequency Offset Compensation Configuration
    0x43, // AGCCTRL2      AGC Control
    0x49, // AGCCTRL1      AGC Control
    0xFB, // WORCTRL       Wake On Radio Control
    0xE9, // FSCAL3        Frequency Synthesizer Calibration
    0x2A, // FSCAL2        Frequency Synthesizer Calibration
    0x00, // FSCAL1        Frequency Synthesizer Calibration
    0x1F, // FSCAL0        Frequency Synthesizer Calibration
    0x81, // TEST2         Various Test Settings
    0x35, // TEST1         Various Test Settings
    0x09, // TEST0         Various Test Settings
};
static uint8_t E07x_Config(uint32_t frequency, uint32_t data_rate, uint32_t frequency_dev, uint32_t bandwidth,
                           int8_t output_power, uint16_t preamble_size, uint16_t sync_word, uint8_t crc)
{
    uint8_t result;
    uint8_t reg_value;

    /* Calculating: Carrier frequency 
     * Register start address  0x0D */
    result = E07x_SetFrequency(frequency);
    if (result != 0)
        return 1;

    /* Calculation: Air speed 
     * MDMCFG4 MDMCFG3 Register address :0x10 0x11 */
    E07x_SetDataRate(data_rate);

    /* Calculation: Frequency Bias 
     * DEVIATN Register address:0x15 */
    E07x_SetFrequencyDeviation(frequency_dev);

    /* Calculate: Receive bandwidth 
     * MDMCFG4 Register address:0x10 */
    E07x_SetChannelBandwidth(bandwidth);

    /* Calculation: Output power 
     * Register address:0x3E */
    E07x_SetOutputPower(output_power);

    /* Modulation mode 
     * MDMCFG2 Register address:0x12 */
    E07x_SetModulation(1); // GFSK

    /* Preamble length 
     * MDMCFG1 Register address:0x13 */
    if (preamble_size > 7)
        return 1;                                     // Parametric check 
    E07x_InitSetting.mdmcfg1 &= 0x8F;                 // Clear 
    E07x_InitSetting.mdmcfg1 |= (preamble_size << 4); // set

    /* Synchronized words 
     * SYNC1 SYNC0 Register address:0x04 0x05 */
    E07x_InitSetting.sync1 = (uint8_t)((sync_word >> 8) & 0xFF); // high Byte
    E07x_InitSetting.sync0 = (uint8_t)(sync_word & 0xFF);        // low Byte

    /* CRC switch 
     * PKTCTRL0 Register address:0x08 bit2 */
    if (crc > 1)
        return 1; // Parametric check which can only be 0 or 1 
    if (crc)
    {
        E07x_InitSetting.pktctrl0 |= 0x04; // turn on
    }
    else
    {
        E07x_InitSetting.pktctrl0 &= 0xFB;
    }

    /* The packet length, which defaults to variable length mode and is placed in the first byte of data 
     * PKTCTRL0 Register address:0x08 bit[1:0] */
    E07x_InitSetting.pktctrl0 &= 0xFC; // clear
    E07x_InitSetting.pktctrl0 |= 0x01; // 0x01 mode (Variable length) 

    /* Note: If you want to use the official SmartRF Studio configuration parameters entirely, you can comment directly on the modified function above */
    /* Write the calculated E07x_InitSetting parameter table to the module  */
    E07x_SetRegister(0x02, E07x_InitSetting.iocfg0);
    E07x_SetRegister(0x03, E07x_InitSetting.fifothr);
    E07x_SetRegister(0x04, E07x_InitSetting.sync1);
    E07x_SetRegister(0x05, E07x_InitSetting.sync0);
    E07x_SetRegister(0x07, 0x05);
    E07x_SetRegister(0x08, E07x_InitSetting.pktctrl0);
    E07x_SetRegister(0x0B, E07x_InitSetting.fsctrl1);
    E07x_SetRegister(0x0D, E07x_InitSetting.freq2);
    E07x_SetRegister(0x0E, E07x_InitSetting.freq1);
    E07x_SetRegister(0x0F, E07x_InitSetting.freq0);
    E07x_SetRegister(0x10, E07x_InitSetting.mdmcfg4);
    E07x_SetRegister(0x11, E07x_InitSetting.mdmcfg3);
    E07x_SetRegister(0x12, E07x_InitSetting.mdmcfg2);
    E07x_SetRegister(0x13, E07x_InitSetting.mdmcfg1);
    E07x_SetRegister(0x15, E07x_InitSetting.deviatn);
    E07x_SetRegister(0x18, E07x_InitSetting.mcsm0);
    E07x_SetRegister(0x19, E07x_InitSetting.foccfg);
    E07x_SetRegister(0x1B, E07x_InitSetting.agcctrl2);
    E07x_SetRegister(0x1C, E07x_InitSetting.agcctrl1);
    E07x_SetRegister(0x20, E07x_InitSetting.worctrl);
    E07x_SetRegister(0x23, E07x_InitSetting.fscal3);
    E07x_SetRegister(0x24, E07x_InitSetting.fscal2);
    E07x_SetRegister(0x25, E07x_InitSetting.fscal1);
    E07x_SetRegister(0x26, E07x_InitSetting.fscal0);
    E07x_SetRegister(0x2C, E07x_InitSetting.test2);
    E07x_SetRegister(0x2D, E07x_InitSetting.test1);
    //    E07x_SetRegister( 0x2E, E07x_InitSetting.test0); //Discover: Setting TEST0 causes custom calculated frequency to shift 
    //Symptom(s): When the frequency point is set to less than 411MHz, the frequency point is locked at 411MHz. Frequency point switching is normal when the frequency point is set to greater than 411MHz 
    // Recommendation: Unannotate TEST0 when the official SmartRF Studio parameters are fully enabled. Leave a comment when calculating with free parameters 

    /* Complementary: Channel coding (which can be used for frequency hopping) register addresses : 0x0A */
    E07x_SetRegister(0x0A, 0);

    /* Supplementary: Turns off the address filtering. register address : 0x07 */
    reg_value = E07x_GetRegister(0x07);
    reg_value &= 0xFC; // clear
    E07x_SetRegister(0x07, reg_value);

    /* Supplementary: Configure the output power. register address : 0x3E */
    E07x_SetRegisters(0x3E, E07x_PaTabel, 8);

    return 0;
}
#define E07_FREQUENCY_START 433000000 // 433 MHz

#define E07_DATA_RATE 1200
#define E07_FREQUENCY_DEVIATION 14300
#define E07_BANDWIDTH 58000
#define E07_OUTPUT_POWER 10
#define E07_PREAMBLE_SIZE 4
#define E07_SYNC_WORD 0x2DD4
#define E07_IS_CRC 1
result = E07x_Config(E07_FREQUENCY_START,
                         E07_DATA_RATE,
                         E07_FREQUENCY_DEVIATION,
                         E07_BANDWIDTH,
                         E07_OUTPUT_POWER,
                         E07_PREAMBLE_SIZE,
                         E07_SYNC_WORD,
                         E07_IS_CRC);

您能帮助检查这个案例吗? 谢谢。

此致、

切里

  • 请注意,本文内容源自机器翻译,可能存在语法或其它翻译错误,仅供参考。如需获取准确内容,请参阅链接中的英语原文或自行翻译。

    您好、Cherry

    不确定我是否已完全理解上述代码以及您实际上是如何读取 RSSI 的。

    作为首次测试、您应执行以下操作:

    void main(void) {
    
        // initialize MCU and peripherals
        initMCU();
    
        // Write radio registers
        registerConfig();
    
        trxSpiCmdStrobe(CC1101_SRX);
        
        do{
          cc1101SpiReadReg(CC1101_MARCSTATE,&marcstate,1);
        } while ((marcstate & 0x1F) != 0x0D);
                
        while(1)
        {
          cc1101SpiReadReg(CC1101_RSSI,&rssi,1);
          // cc1101SpiReadReg(CC1101_LQI,&lqi,1); // No point in reading LQI here as no packets are received
        }
    }

    对于寄存器设置、请使用 SmartRF Studio 给出的一些默认设置。 例如  

    // Address Config = No address check 
    // Base Frequency = 432.999817 
    // CRC Autoflush = false 
    // CRC Enable = true 
    // Carrier Frequency = 432.999817 
    // Channel Number = 0 
    // Channel Spacing = 199.951172 
    // Data Format = Normal mode 
    // Data Rate = 38.3835 
    // Deviation = 20.629883 
    // Device Address = 0 
    // Manchester Enable = false 
    // Modulated = true 
    // Modulation Format = GFSK 
    // PA Ramping = false 
    // Packet Length = 255 
    // Packet Length Mode = Variable packet length mode. Packet length configured by the first byte after sync word 
    // Preamble Count = 4 
    // RX Filter BW = 101.562500 
    // Sync Word Qualifier Mode = 30/32 sync word bits detected 
    // TX Power = 0 
    // Whitening = false 
    // PA table 
    #define PA_TABLE {0x60,0x00,0x00,0x00,0x00,0x00,0x00,0x00}
    
    static const registerSetting_t preferredSettings[]= 
    {
      {CC1101_IOCFG0,      0x06},
      {CC1101_FIFOTHR,     0x47},
      {CC1101_PKTCTRL0,    0x05},
      {CC1101_FSCTRL1,     0x06},
      {CC1101_FREQ2,       0x10},
      {CC1101_FREQ1,       0xA7},
      {CC1101_FREQ0,       0x62},
      {CC1101_MDMCFG4,     0xCA},
      {CC1101_MDMCFG3,     0x83},
      {CC1101_MDMCFG2,     0x13},
      {CC1101_DEVIATN,     0x35},
      {CC1101_MCSM0,       0x18},
      {CC1101_FOCCFG,      0x16},
      {CC1101_AGCCTRL2,    0x43},
      {CC1101_WORCTRL,     0xFB},
      {CC1101_FSCAL3,      0xE9},
      {CC1101_FSCAL2,      0x2A},
      {CC1101_FSCAL1,      0x00},
      {CC1101_FSCAL0,      0x1F},
      {CC1101_TEST2,       0x81},
      {CC1101_TEST1,       0x35},
      {CC1101_TEST0,       0x09},
    };

    当运行上面的代码时、您会看到 RSSI 正在 读数之间变化。

    在这种情况下、LQI 将为0x00、因为该寄存器仅在发现同步字后更新、对于该初始测试、我不会发送任何内容、而只是读取  本底噪声的 RSSI。

    Siri