<?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>Measuring RTT &amp;amp; RSSI through Radio States</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/38480/measuring-rtt-rssi-through-radio-states</link><description>Hi everyone, for the project I&amp;#39;m developing it&amp;#39;s extremely important to measure RTT as accurately as possible and as such, after some SoftDevice specification I imagined the following scenario: 
 
 Both devices would be connected and through the connection</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Nov 2018 12:21:23 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/38480/measuring-rtt-rssi-through-radio-states" /><item><title>RE: Measuring RTT &amp; RSSI through Radio States</title><link>https://devzone.nordicsemi.com/thread/157075?ContentTypeID=1</link><pubDate>Tue, 13 Nov 2018 12:21:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:342f7589-fc6c-4596-9634-eead45ba4517</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Sorry for the late response. Your case fell through the cracks.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I agree with all your reasoning and conclusions. The nRF5 series simply isn&amp;#39;t built for these kinds of things.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I have one last suggestion though. You can look into using the &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/multiprotocol_operation/multiprotocol_support.html?cp=2_3_1_0_8"&gt;Timeslot API&lt;/a&gt;&amp;nbsp;and some sort of custom radio protocol and PPI/software hybrid. Using the timeslot API you can schedule &amp;quot;sessions&amp;quot; where you are allowed to use the radio at your own discretion between the BLE events. With a custom radio protocol you&amp;nbsp;can work&amp;nbsp;directly with the radio peripheral and have complete control what, when, and where things are being transmitted and received. You are also free to use a combination of software and PPI to time the events. You might find some inspiration in this blog post:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/b/blog/posts/wireless-timer-synchronization-among-nrf5-devices"&gt;https://devzone.nordicsemi.com/b/blog/posts/wireless-timer-synchronization-among-nrf5-devices&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring RTT &amp; RSSI through Radio States</title><link>https://devzone.nordicsemi.com/thread/155815?ContentTypeID=1</link><pubDate>Fri, 02 Nov 2018 18:36:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:18f96cbe-e414-4c5e-8416-6177175a8657</guid><dc:creator>M. Corrente</dc:creator><description>&lt;p&gt;Bump&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring RTT &amp; RSSI through Radio States</title><link>https://devzone.nordicsemi.com/thread/150345?ContentTypeID=1</link><pubDate>Tue, 25 Sep 2018 23:04:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:482564a4-6943-4493-b9d1-163430dcfe00</guid><dc:creator>M. Corrente</dc:creator><description>&lt;p&gt;Hi, thank you for the guidance.&lt;/p&gt;
&lt;p&gt;So, with PPI I am able to Start / Stop / Clear timers, however, I need to be able to save their value inbetween connection events and mostly, between links, ideally, it should be done when the radio is in the &amp;quot;t_prep&amp;quot; interval, but I&amp;#39;m guessing that access to radio (and CPU) will still be locked.&lt;/p&gt;
&lt;p&gt;If the t_prep takes from 167us to 1542us I could be possible get a interrupt done through SWI solely to run a fast routine that saves the timers value to some data vector.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1537913518022v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;So, in order to capture the processing delay on the peer, the radio events that PPI will listen to are:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;READY - Clear Timer - Radio is ready&lt;/li&gt;
&lt;li&gt;DEVMATCH - Start Timer - Peer acked packet&lt;/li&gt;
&lt;li&gt;CRCERROR - Stop Timer (and maybe clear) - Dispose&lt;/li&gt;
&lt;li&gt;ADDRESS - Stop Timer - Peer is now Tx&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;After the ADDRESS event, the timer holds the delay value, however, for a multi link situation (the peer will be connected to 3 centrals simultaneously), the next link will just re-start the timer.&lt;/p&gt;
&lt;p&gt;I am not seeing a good solution for this problem. Radio notifications only occur at the beginning and end of the radio event containing multiple links, not usable.&lt;/p&gt;
&lt;p&gt;Another problem is that for each link, multiple packets are exchanged, but it wouldn&amp;#39;t be too bad if I would only be able to get a read on the last one.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1537914328719v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;The only solution I can imagine right now is some sort of external peripheral with some sort of state machine and access to the timers registers, controlled through GPIOTE. That or a completely different approach, using unconnected devices, where the Centrals send SCAN_REQ packets and the peers responds, but still, if the SCAN_REQ arrive in the same connection event, the same issue arises (and collisions would be more frequent).&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1537916122413v3.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Using the given API for PPI I generated the following init for the peer (not tested):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void init_ppi(void)
{
    nrf_ppi_channel_t ppi_ch0, ppi_ch1, ppi_ch2;

    nrfx_ppi_channel_alloc(&amp;amp;ppi_ch0);
    nrfx_ppi_channel_alloc(&amp;amp;ppi_ch1);
    

    // DEV MATCH - Start Timer
    nrfx_ppi_channel_assign(ppi_ch0,
	            &amp;amp;NRF_RADIO-&amp;gt;EVENTS_DEVMATCH,
	            nrf_drv_timer_task_address_get(&amp;amp;delay_counter,
			           NRF_TIMER_TASK_START) );
		
    // CRC ERROR - Stop Timer
    nrfx_ppi_channel_assign(ppi_ch1,
	            &amp;amp;NRF_RADIO-&amp;gt;EVENTS_CRCERROR,
	            nrf_drv_timer_task_address_get(&amp;amp;delay_counter,
			           NRF_TIMER_TASK_STOP) );
	
    // READY - Clear Timer
    nrfx_ppi_channel_fork_assign(NRF_PPI_CHANNEL24,
		 nrf_drv_timer_task_address_get(&amp;amp;delay_counter,
			           NRF_TIMER_TASK_CLEAR));
	
    // ADDRESS - Stop Timer
    nrfx_ppi_channel_fork_assign(NRF_PPI_CHANNEL25,
		 nrf_drv_timer_task_address_get(&amp;amp;delay_counter,
			           NRF_TIMER_TASK_STOP));
    
    uint32_t ppi_mask = (1 &amp;lt;&amp;lt; 0) |
	        (1 &amp;lt;&amp;lt; 1) |
	        (1 &amp;lt;&amp;lt; 2);
	        //(1 &amp;lt;&amp;lt; 25);
    nrfx_ppi_channels_include_in_group(ppi_mask, NRF_PPI_CHANNEL_GROUP0);
    
    nrfx_ppi_group_enable(NRF_PPI_CHANNEL_GROUP0);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;For central devices, they would one be connected to one peer at a time, so measuring the RTT should still be possible using PPI and radio notifications:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;READY - Clear Timer - Radio is ready&lt;/li&gt;
&lt;li&gt;ADDRESS- Start Timer - Packet address sent&lt;/li&gt;
&lt;li&gt;CRCERROR - Stop Timer (and maybe clear) - Dispose&lt;/li&gt;
&lt;li&gt;DEVMATCH- Stop Timer - Receiving Peer Response&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;And through the radio notification (nActive) get the timer values.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;--- UPDATE ---&lt;/p&gt;
&lt;p&gt;So, upon closer inspection of the radio states diagram.&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1537980153198v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;I came to the conclusion that using PPI to Start/Stop the timers alone will not work aswell,&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;For Central Devices (measuring RTT):

[DISABLED]

	--&amp;gt;TXEN
	[TXRU]
	READY					PPI: Clear Timer
	[TXIDLE]
	--&amp;gt;START
		[TX]
			ADDRESS			PPI: Start Timer
			PAYLOAD
			END
	[TXIDLE]
		
	--&amp;gt;RXEN
	[RXRU]
	READY					PPI: Clear Timer
	[RXIDLE]
	--&amp;gt;START
		[RX]
			ADDRESS			PPI: Start Timer
			DEVMATCH		PPI: Stop Timer
			PAYLOAD
			END
	[RXIDLE]
	
	--&amp;gt;DISABLE
[DISABLED]



For the Peer Device (measuring Processing Delay):

[DISABLED]

	--&amp;gt;RXEN
	[RXRU]
	READY					PPI: Clear Timer
	[RXIDLE]
	--&amp;gt;START
		[RX]
			ADDRESS			PPI: Stop Timer
			DEVMATCH		PPI: Start Timer
			PAYLOAD
			END
	[RXIDLE]

	--&amp;gt;TXEN
	[TXRU]
	READY					PPI: Clear Timer
	[TXIDLE]
	--&amp;gt;START
		[TX]
			ADDRESS			PPI: Stop Timer
			PAYLOAD
			END
	[TXIDLE]
	
	--&amp;gt;DISABLE
[DISABLED]&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Legend:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;[ ] - Radio States;&lt;/li&gt;
&lt;li&gt;--&amp;gt; - Tasks;&lt;/li&gt;
&lt;li&gt;Simple words - Events that PPI can use.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Without knowing if the radio is currently in Tx or Rx mode and use Start/Stop accordingly, it just seems impossible.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the assistance,&lt;/p&gt;
&lt;p&gt;Marco.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Measuring RTT &amp; RSSI through Radio States</title><link>https://devzone.nordicsemi.com/thread/148632?ContentTypeID=1</link><pubDate>Thu, 13 Sep 2018 13:07:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2182dd5c-9e8f-46e3-959a-109314aa387d</guid><dc:creator>MartinBL</dc:creator><description>&lt;p&gt;When the Softdevice is enabled your access to the Radio peripheral is blocked. &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/sd_resource_reqs/hw_block_interrupt_vector.html?cp=2_3_1_0_6_0"&gt;Here is a list&lt;/a&gt; of blocked and restricted peripherals.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can look into using &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.sds/dita/softdevices/s130/radio_notif/radio_notification.html?cp=2_3_1_0_10"&gt;Radio Notifications&lt;/a&gt; instead. It allows you to get notified whenever the radio ramps up or down. &lt;a href="https://devzone.nordicsemi.com/tutorials/b/software-development-kit/posts/radio-notification"&gt;Here is a (somewhat outdated) tutorial&lt;/a&gt;.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You might also look into using &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.nrf52832.ps.v1.1/ppi.html?cp=2_1_0_21#concept_sxf_21l_1s"&gt;PPI&lt;/a&gt; to start and stop your timers directly on specific radio events.&amp;nbsp;To get you started you can use this simple code to&amp;nbsp;make LED 4 toggle each time a packet is sent or received:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void toggle_gpio_on_radio_end_event()
{
    NRF_GPIOTE-&amp;gt;CONFIG[0] = (GPIOTE_CONFIG_MODE_Task &amp;lt;&amp;lt; GPIOTE_CONFIG_MODE_Pos) |
                            (LED_4 &amp;lt;&amp;lt; GPIOTE_CONFIG_PSEL_Pos) |
                            (GPIOTE_CONFIG_POLARITY_Toggle &amp;lt;&amp;lt; GPIOTE_CONFIG_POLARITY_Pos) |
                            (GPIOTE_CONFIG_OUTINIT_Low &amp;lt;&amp;lt; GPIOTE_CONFIG_OUTINIT_Pos);
    NRF_PPI-&amp;gt;CH[0].EEP = (uint32_t)&amp;amp;NRF_RADIO-&amp;gt;EVENTS_END;
    NRF_PPI-&amp;gt;CH[0].TEP = (uint32_t)&amp;amp;NRF_GPIOTE-&amp;gt;TASKS_OUT[0];
    NRF_PPI-&amp;gt;CHENSET |= 1;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>