<?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>nRF Connect SDK - fast RSSI sampling maybe via nrfxlib</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84336/nrf-connect-sdk---fast-rssi-sampling-maybe-via-nrfxlib</link><description>Hi, 
 I would like to port an existing contiki-ng code to nRF Connect SDK. Within this code, I need to sample the 2.4GHz radio RSSI value around 50000 times in a short time. My first try was by using the nrf_802154.h library from nrfxlib. Please find</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Feb 2022 11:13:35 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84336/nrf-connect-sdk---fast-rssi-sampling-maybe-via-nrfxlib" /><item><title>RE: nRF Connect SDK - fast RSSI sampling maybe via nrfxlib</title><link>https://devzone.nordicsemi.com/thread/352292?ContentTypeID=1</link><pubDate>Thu, 10 Feb 2022 11:13:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:925c2ec4-fb62-473c-a05e-7fd7c5df5eac</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Andi&lt;/p&gt;
&lt;p&gt;Because the RSSI signal is filtered it will take 15us for any change in signal strength seen by the receiver to be fully reflected in the value you read out through the RSSISAMPLE register.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Put another way, what you read out of the RSSISAMPLE register is an average of all the RSSI values for the previous 15 microseconds.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As an example, say the RSSI level changes abruptly from -80dBm to -60dBm it will take 15us before you read -60dBm out of the RSSISAMPLE register, and if you sample many times before that you will just get a slow ramp between -80dBm and -60dBm (the filtered value).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you later want to average these values then you are essentially doing double work, since the filtering is already averaging the signal, and the averaged result should be the same whether you sample at 15us or faster.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;If you want to get an accurate estimate of how the RSSI value is changing over time (rather than an average) then sampling faster than 15us doesn&amp;#39;t really help either, since you will only be recording the effect of the filter and not the exact RSSI value.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Using my example earlier you would see a smooth transition between -80 to -60 dBm over a period of ~15us, while in reality the RSSI changed immediately.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The reason the RSSI period is shorter is that it is useful not to be forced to wait 15us&amp;nbsp;every time you sample the RSSI, but if you already did an RSSI sampling less than 15us prior then you will only be reading out a mix of the old value and the new.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK - fast RSSI sampling maybe via nrfxlib</title><link>https://devzone.nordicsemi.com/thread/352027?ContentTypeID=1</link><pubDate>Wed, 09 Feb 2022 11:16:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:33a75f9a-d0e8-471c-919a-c6a438da9bdd</guid><dc:creator>whati001</dc:creator><description>&lt;p&gt;Hi Torbj&amp;oslash;rn,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;it&amp;#39;s hilarious, but I am not even sure if I need such a fast sampling rate. Normally the 14.7us should be sufficient.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;However, the exiting code does the sampling in such a way, so I have just searched for a way to port it 1:1 before optimizing it. I have exactly turned your suggestion into code, please find below the snipped. By using this function we can sample the 50000 values within 69ms.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;hal/nrf_radio.h&amp;gt;
#include &amp;lt;mdk/nrf52840.h&amp;gt;

int8_t nrf_hal_get_rssi(void)
{
	nrf_radio_event_clear(NRF_RADIO, NRF_RADIO_EVENT_RSSIEND);
	nrf_radio_task_trigger(NRF_RADIO, NRF_RADIO_TASK_RSSISTART);
	while (!nrf_radio_event_check(NRF_RADIO, NRF_RADIO_EVENT_RSSIEND))
	{
	}

	uint8_t rssi_sample = nrf_radio_rssi_sample_get(NRF_RADIO);
	return -((int8_t)rssi_sample);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Sorry, but I am not so deep in this domain yet. If I checkout your proposed documentation &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fps_nrf52840%2Fradio.html&amp;amp;cp=4_0_0_5_19_14_8&amp;amp;anchor=unique_1927333262"&gt;here&lt;/a&gt;, I would conclude, that a new RSSI value would be ready for reading after triggering RSSI_START and waiting (0.25us) RSSI&lt;sub class="ph sub"&gt;PERIOD&lt;/sub&gt; time. Because this is what the description of RSSI&lt;sub class="ph sub"&gt;PERIOD&lt;/sub&gt; states.&lt;/p&gt;
&lt;p&gt;Therefore, I am still not sure what the RSSI&lt;sub class="ph sub"&gt;SETTLE&lt;/sub&gt; refers to. Can we only expect changes in the read RSSI value after this amount of time (15us)? Argo, the sample code above would always read the same value until the 15us are passed?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Please help me to understand the difference between RSSI&lt;sub class="ph sub"&gt;PERIOD&lt;/sub&gt; and RSSI&lt;sub class="ph sub"&gt;SETTLE&lt;/sub&gt; .&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Andi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK - fast RSSI sampling maybe via nrfxlib</title><link>https://devzone.nordicsemi.com/thread/352013?ContentTypeID=1</link><pubDate>Wed, 09 Feb 2022 10:32:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e9628376-4cb1-4d16-9cd5-33c58bde10ed</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Andi&lt;/p&gt;
&lt;p&gt;I discussed this with the developer, and apparently there is no way to read the RSSI faster through the library.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You could bypass the library altogether, and read the RSSI through the registers:&lt;/p&gt;
&lt;p&gt;1) Clear the RSSIEND event&lt;br /&gt;2) Trigger the RSSISTART task&lt;br /&gt;3) Wait for the RSSIEND event to be set&lt;br /&gt;4) Read the RSSI from the RSSISAMPLE register&lt;/p&gt;
&lt;p&gt;This is a bit of a dirty hack though. Also, I still don&amp;#39;t see the point of oversampling a filtered signal. Essentially you are just burning through CPU cycles and power to sample a bit of extra noise.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK - fast RSSI sampling maybe via nrfxlib</title><link>https://devzone.nordicsemi.com/thread/351594?ContentTypeID=1</link><pubDate>Mon, 07 Feb 2022 15:06:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:934f6af2-3b09-4102-9d64-217aa378e084</guid><dc:creator>whati001</dc:creator><description>&lt;p&gt;Hi Torbj&amp;oslash;rn, &lt;/p&gt;
&lt;p&gt;thank you very much for this hint. Just to get everything right, do we need to wait for this specific settle time before reading each RSSI value or just if the value has changed?&lt;/p&gt;
&lt;p&gt;If we have a look into the nrf802154 source code, I can observer the wait here &lt;a href="https://github.com/nrfconnect/sdk-nrfxlib/blob/5e4a91c26f8be934b74e6c42c72f7e8c60cf054a/nrf_802154/driver/src/nrf_802154_trx.c#L1101"&gt;nrf_802154_trx.c#L1101&lt;/a&gt;. However, this wait get&amp;#39;s only executed if we have received a frame beforehand. &lt;/p&gt;
&lt;p&gt;This is not the case in my example code and using an constant jammer sending some garbage. Therefore, the wait is only executed ones, exactly for the first package (tested via a printf).&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;So my question has changed to: Are we able to read RSSI values faster than this settle time or not?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Regards&lt;/p&gt;
&lt;p&gt;Andi&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF Connect SDK - fast RSSI sampling maybe via nrfxlib</title><link>https://devzone.nordicsemi.com/thread/351094?ContentTypeID=1</link><pubDate>Thu, 03 Feb 2022 12:35:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83ff02e6-320b-442d-b5d2-ac5b656f7b56</guid><dc:creator>ovrebekk</dc:creator><description>&lt;p&gt;Hi Andreas&lt;/p&gt;
&lt;p&gt;If I understand you correctly the ncs code allows you to sample the RSSI 50000 times in 735ms?&lt;/p&gt;
&lt;p&gt;This matches pretty well with the RSSI settling time, which is 15us as documented &lt;a href="https://infocenter.nordicsemi.com/topic/ps_nrf52840/radio.html?cp=4_0_0_5_19_14_8#unique_1927333262"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;735ms / 50000 =&amp;nbsp; 14.7us&lt;/p&gt;
&lt;p&gt;There is no gain in sampling the RSSI faster than the sampling time,&amp;nbsp;since the RSSI value is filtered and will not change fast enough to provide any additional information.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I am not sure where your requirement of sampling the RSSI 50000 times comes from, but if you reduce the number of samples so that the total time is similar the end result should be the same.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards&lt;br /&gt;Torbjørn&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>