TI中文支持网
TI专业的中文技术问题搜集分享网站

CC1101: RSSI LQI讀取為定值,但是CC1101可以正常通訊

Part Number:CC1101

讀取暫存器資料RSSI 與LQI一直為定值,只有在特定無法收訊的時候會產生值得變化

讀取方式有使用過直接讀取對應暫存器 0x33 [0xF3] 0x34[0xF4] 
也有採取開啟暫存器設定  0x07:PKTCTRL1為0x05後讀取與BUFFER後的兩位
讀取暫存器資料RSSI 與LQI一直為定值 ,沒辦法獲得RSSI 與LQI 的數值從而沒辦法知道天線的好壞
我是否需要在特定的時間點讀取RSSI和LQI的值,例如在接收到一個包之後?
我是否需要配置任何特定的寄存器或設置才能正確讀取RSSI和LQI?
我的硬體和天線配置是否可能影響RSSI和LQI的讀取?
是否有任何特定的信號條件或環境因素可能影響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;

    /* 計算:載波頻率
     * 寄存器起始位址 0x0D */
    result = E07x_SetFrequency(frequency);
    if (result != 0)
        return 1;

    /* 計算:空速
     * MDMCFG4 MDMCFG3寄存器位址:0x10 0x11 */
    E07x_SetDataRate(data_rate);

    /* 計算:頻偏
     * DEVIATN寄存器位址:0x15 */
    E07x_SetFrequencyDeviation(frequency_dev);

    /* 計算:接收頻寬
     * MDMCFG4寄存器位址:0x10 */
    E07x_SetChannelBandwidth(bandwidth);

    /* 計算:輸出功率
     * 寄存器位址:0x3E */
    E07x_SetOutputPower(output_power);

    /* 調製模式
     * MDMCFG2 寄存器位址:0x12 */
    E07x_SetModulation(1); // GFSK

    /* 前導碼長度
     * MDMCFG1 寄存器位址:0x13 */
    if (preamble_size > 7)
        return 1;                                     // 參數檢查
    E07x_InitSetting.mdmcfg1 &= 0x8F;                 // 清零
    E07x_InitSetting.mdmcfg1 |= (preamble_size << 4); // 置位

    /* 同步字
     * SYNC1 SYNC0 寄存器位址:0x04 0x05 */
    E07x_InitSetting.sync1 = (uint8_t)((sync_word >> 8) & 0xFF); // 高Byte
    E07x_InitSetting.sync0 = (uint8_t)(sync_word & 0xFF);        // 低Byte

    /* CRC開關
     * PKTCTRL0寄存器位址:0x08 bit2 */
    if (crc > 1)
        return 1; // 參數檢查 只能為0或1
    if (crc)
    {
        E07x_InitSetting.pktctrl0 |= 0x04; // 開啟
    }
    else
    {
        E07x_InitSetting.pktctrl0 &= 0xFB;
    }

    /* 資料包長度 預設為可變長模式且長度放在資料第一位元組
     * PKTCTRL0寄存器位址:0x08 bit[1:0] */
    E07x_InitSetting.pktctrl0 &= 0xFC; // 清零
    E07x_InitSetting.pktctrl0 |= 0x01; // 0x01模式 (可變長)

    /* 注意事項:如果希望完全使用官方SmartRF Studio的配置參數,那麼直接注釋掉上方的修改函數即可 */
    /* 向模組寫入計算後的 E07x_InitSetting 參數表 */
    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); //發現: 設置TEST0導致自訂計算頻率偏移
    // 現象: 當頻點設置為小於411MHz時,頻點鎖死在了411MHz。當頻點設置為大於411MHz時,頻點切換正常
    // 建議: 當完全啟用官方SmartRF Studio參數時,解除TEST0的注釋。當使用自由參數計算時,保持注釋

    /* 補充:通道編碼(可用於跳頻)  寄存器位址: 0x0A */
    E07x_SetRegister(0x0A, 0);

    /* 補充:關閉位址過濾  寄存器位址: 0x07 */
    reg_value = E07x_GetRegister(0x07);
    reg_value &= 0xFC; // 清零
    E07x_SetRegister(0x07, reg_value);

    /* 補充: 配置輸出功率 寄存器位址: 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 Zhou:

您好,您的问题我们需要升级到英文论坛寻求帮助,有答复尽快给到您。

,

Cherry Zhou:

您好,请看如下答复:

不确定是否已完全理解上述代码以及您实际上是如何读取 RSSI 的。 作为首次测试,您应执行以下操作: 

void main(void) {// initialize MCU and peripheralsinitMCU();// Write radio registersregisterConfig();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。 

赞(0)
未经允许不得转载:TI中文支持网 » CC1101: RSSI LQI讀取為定值,但是CC1101可以正常通訊
分享到: 更多 (0)