nrf5340 RSSI with DTM or Radio_test example

Hi,

We may need to using the DTM or Radio_test example to get the RSSi of recevied packet.

Is thay can working on nrf5340 SDK 2.4.0?

  • Hi,

    I think you need to modify both samples so that they have a function that reads the RSSI register. To read out the RSSI, you first have to trigger the Task TASKS_RSSISTART, and then wait for the EVENTS_RSSIEND to be generated. Once that event is generated, you can read out the result from the RSSISAMPLE.

    regards

    Jared 

  • Hi Jared,

    I add the below code in the "on_radio_end_event"  at dtm.c line:2238.

        if (nrf_radio_crc_status_check(NRF_RADIO) &&
            check_pdu(received_pdu)) {
            /* Count the number of successfully received
             * packets.
             */
            dtm_inst.rx_pkt_count++;
            NRF_RADIO->TASKS_RSSISTART = 1;
            while(!NRF_RADIO->EVENTS_RSSIEND)
            {
                printk("wait rssi end\r\n");
            };
            printk("%d\n", NRF_RADIO->RSSISAMPLE);
        }
    But I always get  the RSSI value is 127, could you help to check what issue come from?
  • Hi.

    The RSSI doesn't specify which peer that the package comes from? It could be something close to the device that is sending the -127 RSSI packet. Do you trigger the START task before each turn?

    Also, from the documentation:

    For the RSSI sample to be valid, RADIO has to be enabled in RX mode (RXEN task) and the reception has to be started (READY event followed by START task).

    regards
    Jared

  • Hi, 

    Now I add the below add code in "static void radio_prepare(bool rx)" of dtm.c

    // add+
            NRF_RADIO->EVENTS_READY = 0;
    // add-  
            radio_start(rx, false);
    // add+
            while(!NRF_RADIO->EVENTS_RXREADY);
            NRF_RADIO->TASKS_RSSISTART = 1;
    // add-
    And read the rssi in "static void on_radio_end_event(void)"
            dtm_inst.rx_pkt_count++;
    // add+
            while(!NRF_RADIO->EVENTS_RSSIEND)
            {
                printk("wait rssi end\r\n");
            };
            printk("%d\n", NRF_RADIO->RSSISAMPLE);
            NRF_RADIO->EVENTS_READY = 0;
            while(!NRF_RADIO->EVENTS_RXREADY);
            NRF_RADIO->TASKS_RSSISTART = 1;
    // add-
    Result is I can get the RSSI value in first packet received is correct, then the rssi value become -127.
    Where should I add the "NRF_RADIO->TASKS_RSSISTART = 1;" in dtm.c to let every packet can get the RSSI value?
  • Hi,

    You need to clear the NRF_RADIO->EVENTS_RSSIEND event by setting it to 0 in between starting the task again,

    something like this:

    uint8_t rssi(void)
    {
        NRF_RADIO->EVENTS_RSSIEND = 0;
        NRF_RADIO->TASKS_RSSISTART = 1;
        while (NRF_RADIO->EVENTS_RSSIEND == 0);
        uint8_t rssi = NRF_RADIO->RSSISAMPLE;
        return rssi;
    }
    

    regards

    Jared 

Related