<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/116053/reading-the-rssisample-register-is-very-time-consuming-using-the-esb-in-nrf52833-approximately-400-500ms-each-time</link><description>When I used the code to get the RSSI values for different channels, I found that it was very time-consuming, about 400-500ms, and most of the time was spent waiting (NRF_RADIO-&amp;gt;EVENTS_RSSIEND = 1. May I ask why this is? Is there a way to optimize it?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 12 Nov 2024 18:25:04 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/116053/reading-the-rssisample-register-is-very-time-consuming-using-the-esb-in-nrf52833-approximately-400-500ms-each-time" /><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/510185?ContentTypeID=1</link><pubDate>Tue, 12 Nov 2024 18:25:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:479186b2-6f56-4efc-a3dd-75de644eb9e4</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;ESB does not implement this functionality, you have to implement that yourself. i.e. it will not out-of-the-box select the channel with lowest noise level.&amp;nbsp;&lt;span style="font-family:inherit;"&gt;You can change the channel using the function&amp;nbsp;&lt;/span&gt;&lt;span style="font-family:inherit;"&gt;esb_set_rf_channel(), by default it will just stay on 1 single channel.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/509796?ContentTypeID=1</link><pubDate>Mon, 11 Nov 2024 06:34:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a8282d13-dd57-45d5-a5fa-dec5eb67c133</guid><dc:creator>langzou</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi! &lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;There are some questions. Before connection, does the RSSI scanned on different channels by RX represent the noise level on different channels? Assuming these pre-connection RSSI values on different channels are used as the basis for connection channels, should the channel corresponding to the maximum or minimum RSSI be chosen?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/509077?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 10:18:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1379971d-aab5-4ac7-b5ff-7f3d8e73b4fe</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
[quote user="langzou"]Why is it still time-consuming when I use the code you provided[/quote]
&lt;p&gt;What time are you measuring with the code I provided? If you run it on top of ESB, then I guess you have configured the radio to a specific addresses, etc, and only receive packets from specific devices. So the time it takes to get the RSSI measurement will depend on how often these devices transmit.&lt;/p&gt;
[quote user="langzou"]Additionally, the RSSI obtained through the method you provided differs greatly from the RSSI after an actual connection is established[/quote]
&lt;p&gt;You are only interesting the RSSI for the device you are connected to?&lt;/p&gt;
[quote user="langzou"]I noticed that you did not stop RX before setting the Frequency, and you did not restart RX after setting it.[/quote]
&lt;p&gt;The&amp;nbsp;RX is started in the beginning of&amp;nbsp;rssi_measurer_scan_channel(). At the end of that function, the RX is disabled.&lt;/p&gt;
[quote user="langzou"]Is it that the RX reception during broadcasting is measuring the RSSI of the noise in the environment?[/quote]
&lt;p&gt;It&amp;#39;s measuring RSSI of noise in the &lt;span&gt;environment.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/509028?ContentTypeID=1</link><pubDate>Tue, 05 Nov 2024 02:56:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9d7a0836-fdb2-492e-b560-599d45e3554a</guid><dc:creator>langzou</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thank you very much for your reply. I still have a few questions I would like to ask you.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Why is it still time-consuming when I use the code you provided, and why does it easily trigger a watchdog reset? Additionally, the RSSI obtained through the method you provided differs greatly from the RSSI after an actual connection is established, with a difference of about 30-40 in value. I noticed that you did not stop RX before setting the Frequency, and you did not restart RX after setting it. Is it that the RX reception during broadcasting is measuring the RSSI of the noise in the environment?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/509003?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2024 18:21:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c1fc88aa-2acf-4db4-aaf9-e770013ea380</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;boards.h&amp;quot;
#include &amp;quot;bsp.h&amp;quot;
#include &amp;quot;app_timer.h&amp;quot;
#include &amp;quot;nordic_common.h&amp;quot;
#include &amp;quot;nrf_error.h&amp;quot;

#include &amp;quot;nrf_gpio.h&amp;quot;

#define max_channel      80   
static uint32_t scan_repeat_times = 1;

#define RSSI_NO_SIGNAL              127    /**&amp;lt; Minimum value of RSSISAMPLE */

#define PIN_GPIO  (4UL)

void rssi_measurer_configure_radio(void)
{
	NRF_RADIO-&amp;gt;POWER  = 1;
	NRF_RADIO-&amp;gt;SHORTS = RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_DISABLE_Msk;
	NVIC_EnableIRQ(RADIO_IRQn);

	NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;
	while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);
}

#define WAIT_FOR( m ) do { while (!m); m = 0; } while(0)

uint8_t rssi_measurer_scan_channel(uint8_t channel_number)
{
	uint8_t sample;

	NRF_RADIO-&amp;gt;FREQUENCY  = channel_number;
	NRF_RADIO-&amp;gt;TASKS_RXEN = 1;

	WAIT_FOR(NRF_RADIO-&amp;gt;EVENTS_READY);
	NRF_RADIO-&amp;gt;TASKS_RSSISTART = 1;
	WAIT_FOR(NRF_RADIO-&amp;gt;EVENTS_RSSIEND);

	sample = 127 &amp;amp; NRF_RADIO-&amp;gt;RSSISAMPLE;

	NRF_RADIO-&amp;gt;TASKS_DISABLE = 1;
	WAIT_FOR(NRF_RADIO-&amp;gt;EVENTS_DISABLED);

	return sample;
}

uint8_t rssi_measurer_scan_channel_repeat(uint8_t channel_number)
{
	uint8_t sample;
	uint8_t max = RSSI_NO_SIGNAL;
	for (int i = 0; i &amp;lt;= scan_repeat_times; ++i) {
		sample = rssi_measurer_scan_channel(channel_number);
		// taking minimum since sample = -dBm.
		max = MIN(sample, max);
	}
	return max;
}



/**
 * @brief Function for application main entry.
 */
int main(void)
{

    static uint8_t sample[max_channel];

    nrf_gpio_cfg_output(PIN_GPIO);


   rssi_measurer_configure_radio();

 
 nrf_gpio_pin_toggle(PIN_GPIO);

  for (uint8_t i = min_channel; i &amp;lt;= max_channel; ++i)
  {
          sample[i] = rssi_measurer_scan_channel_repeat(i);
  }
   nrf_gpio_pin_toggle(PIN_GPIO);



    while (true)
    {
        __SEV();
        __WFE();
        __WFE();
      
    }
}


/** @} */
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This takes ~20ms to scan 80 channels (time measured with gpio toggling).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/508972?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2024 14:12:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6ada7458-251f-4c52-8646-546557bcfa1e</guid><dc:creator>langzou</dc:creator><description>&lt;p&gt;&lt;span&gt;Why is &amp;quot;while(NRF_RADIO-&amp;gt;EVENTS_RSSIEND == 0);&amp;quot; so time-consuming? Is it inherently so time-consuming in theory or is there an issue with my&amp;nbsp;code somewhere?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/508971?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2024 14:09:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dc785e2-39c3-4030-9d8e-fc00fcaf018c</guid><dc:creator>langzou</dc:creator><description>&lt;p&gt;Yes, I have tried to remove the &amp;quot;&lt;span&gt;NRF_RADIO-&amp;gt;TASKS_RSSISTART = 0&lt;/span&gt;&amp;quot; and the problem still arises. The way to measure the time is to obtain the system time before and after the &amp;quot;while(NRF_RADIO-&amp;gt;EVENTS_RSSIEND == 0)&amp;quot;, and find that the interval is about 400ms.&amp;nbsp;&lt;span&gt;Before each wireless connection, the function esb_get_rf_channel_rssi is repeatedly called to obtain the RSSI for each channel.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading the RSSISAMPLE register is very time-consuming using the ESB in nRF52833 (approximately 400-500ms each time).</title><link>https://devzone.nordicsemi.com/thread/508960?ContentTypeID=1</link><pubDate>Mon, 04 Nov 2024 13:39:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00678760-9f31-4736-bef2-accd94b6243f</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;This line here does nothing, so you can remove that:&lt;/p&gt;
&lt;p&gt;&amp;nbsp;NRF_RADIO-&amp;gt;TASKS_RSSISTART = 0;&lt;/p&gt;
&lt;p&gt;How are you measuring the time? Are you calling&amp;nbsp;esb_get_rf_channel_rssi in a loop?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>