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值,为什么有时有,有时没有?是正常现象吗?

Other Parts Discussed in Thread: CC1101

我想利用CC1101获取RSSI值,下面是我的while循环

while( 1 )
{
CC1101_Clear_RxBuffer( );
CC1101_Set_Mode( RX_MODE );
i = CC1101_Rx_Packet( g_CC1101RxBuffer ); //接收字节
if( 0 != i )
{

rssi_dec = CC1101_Read_Status(0x34);//获取RSSI值
delay_ms(10);
g_CC1101RxBuffer[9] = rssi_dec;

printf("\r\n您发送的消息为:\r\n");
for(t=0;t<10;t++)
{
USART_SendData(USART1, g_CC1101RxBuffer[t]); //向串口1发送数据
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)!=SET);//等待发送结束
}
printf("\r\n\r\n");//插入换行

}

为什么每两次或者三次才能获取一次RSSI值,发射是每50ms一次(我感觉和这个没关系,因为我改成一秒一次,也是每隔两次才能得到一次),这个值rssi_dec 的格式为unsigned          char,读出来的值一般很小,不知道对不对,比如说我在1米的时候读的是4,在2.5米的时候读的是40多,不知道对不对?

具体看下图,

这是1米左右的RSSI值为4,不知道对不对?

这是2.5米处的RSSI值,不太准确,以ASCII码显示的,其值以十进制显示的话在41~47波动,这个值是不是不准确?

请帮忙看一下

  • 只有CC1101芯片处在rx状态下时,才能侦测到信道上的RSSI值

    所以,有两种途径获取RSSI值

    1. 通过读取rssi寄存器

    2. 通过读取接收到的数据后面append的status字节中的rssi信息

    以下是CC1101手册中RSSI的相关描述,更多细节可参看CC1101手册17.3章节

    In RX mode, the RSSI value can be read continuously from the RSSI status register until the demodulator detects a sync word (when sync word detection is nabled). At that point the RSSI readout value is frozen until the next time the chip enters the RX state.

  • 搞定了,代码没错了

  • 从RSSI寄存器读到的值是需要转换的。

    The RSSI value read from the RSSI status
    register is a 2’s complement number. The
    following procedure can be used to convert the
    RSSI reading to an absolute power level
    (RSSI_dBm)
    1) Read the RSSI status register
    2) Convert the reading from a hexadecimal
    number to a decimal number (RSSI_dec)
    3) If RSSI_dec ≥ 128 then RSSI_dBm =
    (RSSI_dec - 256)/2 – RSSI_offset

    4) Else if RSSI_dec < 128 then RSSI_dBm =
    (RSSI_dec)/2 – RSSI_offset
    Table 31 gives typical values for the
    RSSI_offset. Figure 22 and Figure 23 show

    typical plots of RSSI readings as a function of
    input power level for different data rates.

     

  • 2) Convert the reading from a hexadecimal
    number to a decimal number (RSSI_dec)

    这一步是不是没有必要,直接可以进行第三步?

  • 主要就是以无符号整形却解析这个十六进制数

    继而有后面与128比大小的操作

  • 如何解析呢?比如说我读的是42(十六进制),不是直接可以放到后面和这个128相比较的操作?

    vs16 CC1101_CalculateRSSI(u8 RSSI_dec)
    {
    vs16 RSSI_dBm;
    u8 RSSI_offset = 74;
    if (RSSI_dec >= 128)
    RSSI_dBm = (u16)((u16)( RSSI_dec - 256) / 2) - RSSI_offset;
    else
    RSSI_dBm = (RSSI_dec / 2) - RSSI_offset;


    return RSSI_dBm;
    }

    这上面就是比较函数,RSSI_dec是直接从寄存器得到的16进制RSSI值,是不是这样处理就可以?

  • 请问这个在1米的距离读取的40~42(16进制),是不是正确的呢?你们能给出大致范围吗?

    @Felix ZF