<?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>Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/61296/configure-radio-at-nrf52811-for-antenna-switching</link><description>Hello. I try to configure radio at NRF52811 to prepare antenna switching and get correct I/Q samples from different antennas. I have 2 antennas that are 6 cm apart from one another. They are connected to the chip through RF switch BGS12SN6E6327XTSA1.</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 May 2020 18:04:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/61296/configure-radio-at-nrf52811-for-antenna-switching" /><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/252277?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 18:04:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c3f4556-306b-4113-934b-6838889ae278</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Now it looks right. Yes, the first 64 samples are reference period, then you have blocks by 16 samples from two antennas (two times of switching-sampling slots). You should take samples close to the end of sampling slot (when transition is complete). As I can see, transition is not complete fully in 8 samples, try to configure switching&amp;nbsp;pin in high-drive mode, maybe you need to increase your slot to 2 usec.&lt;/p&gt;
&lt;p&gt;One point unclear to me - the reference period has 250-kHz slope as expected, then your line is almost flat, not considering antenna switching. Looks like CTE is run out just after reference period, and then you&amp;#39;re receiving a central frequency carrier (inter-frame&amp;nbsp;space). Or maybe you&amp;nbsp;have already implemented an offset compensation?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/252244?ContentTypeID=1</link><pubDate>Thu, 28 May 2020 14:26:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e70c06b5-4701-40c3-878d-5426dc47c83c</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;So, thanks, finally I get something, that seems better (blue line - 90-45-0 degrees, red line&amp;nbsp; - Aj-Aj-1):&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_27-_3204_-15.26.02.png" /&gt;&lt;/p&gt;
&lt;p&gt;Histogram above is not from the first sample. And there is full graph:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/824832.1.png" /&gt;&lt;/p&gt;
&lt;p&gt;(or&amp;nbsp;&lt;a href="https://drive.google.com/file/d/1a0Z3jI6ciaaDey2JHpE1_Ma7HtqVN38N/view?usp=sharing"&gt;https://drive.google.com/file/d/1a0Z3jI6ciaaDey2JHpE1_Ma7HtqVN38N/view?usp=sharing&lt;/a&gt;)&lt;/p&gt;
&lt;p&gt;But there is still not clear how to get angle from it? With configuration above&amp;nbsp;&lt;span&gt;which samples belong to the first, and which to the second antenna? As I understand from the graph and configuration, first ~80 samples are from reference period, and then every 16 samples received from different antennas. Am I correct?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/251544?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 15:06:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7e8f64c4-1e5c-426c-bd7a-48b288870f93</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote userid="90254" url="~/f/nordic-q-a/61296/configure-radio-at-nrf52811-for-antenna-switching/251516"]How to enable CRC in RADIO example? [/quote]
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;// CRC Config
NRF_RADIO-&amp;gt;CRCCNF = (RADIO_CRCCNF_LEN_Two &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos); // Number of checksum bits
//NRF_RADIO-&amp;gt;CRCCNF = (RADIO_CRCCNF_LEN_Disabled &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos);&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/251516?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 13:51:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8732463f-8f4a-446b-8a68-da7b8c737572</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;How to enable CRC in RADIO example? Thanks&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/251515?ContentTypeID=1</link><pubDate>Mon, 25 May 2020 13:50:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:612e30ae-2188-4087-a893-3dd12cbdc344</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I changed the settings to 125ns and this is what data I got at different angles to the antennas line. The shift is the same again:&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/chart-_2800_5_2900_.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/251072?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 18:08:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:91875c68-e878-43bc-84d4-e834a478fa31</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Now you&amp;#39;re receiving your payload as I/Q samples (RADIO_DFECTRL1_DFEINEXTENSION_Payload).&amp;nbsp;I suggested it just to look at phase graph - whether you&amp;#39;re receiving something meaningful, but with 1-us sampling we won&amp;#39;t see anything.&lt;/p&gt;
&lt;p&gt;Did you try to enable CRC with &lt;span&gt;RADIO_DFECTRL1_DFEINEXTENSION_CRC setting? And leave sampling interval of 0.125us for now - there will be much clear picture. There should be a continuous graph except the gap after first 8 us. Here&amp;nbsp;you can see&amp;nbsp;my results (though I use different algorithm to get phase value): samples 0-63 are for reference period, then the gap (first switching slot), then switching/sampling slots.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1589997573811v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/251058?ContentTypeID=1</link><pubDate>Wed, 20 May 2020 15:35:34 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee55fde7-151c-40b4-9572-2ec05ec538d4</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;I&amp;#39;ve some updates:&lt;/p&gt;
&lt;p&gt;1. RF switch and both&amp;nbsp;&lt;span&gt;antennas&amp;nbsp;&lt;/span&gt;work correctly,&amp;nbsp;switching occurs.&lt;/p&gt;
&lt;p&gt;2.&amp;nbsp;I changed the settings a bit:&lt;/p&gt;
&lt;p&gt;Also I changed&amp;nbsp;&lt;span&gt;MAXCNT:&amp;nbsp;&lt;/span&gt;NRF_RADIO-&amp;gt;DFEPACKET.MAXCNT = MAXCNT1 / 2;&lt;pre class="ui-code" data-mode="c_cpp"&gt;NRF_RADIO-&amp;gt;DFECTRL1 =     31                                    &amp;lt;&amp;lt; RADIO_DFECTRL1_NUMBEROF8US_Pos |
                              RADIO_DFECTRL1_DFEINEXTENSION_Payload     &amp;lt;&amp;lt; RADIO_DFECTRL1_DFEINEXTENSION_Pos |
                              RADIO_DFECTRL1_TSAMPLESPACINGREF_1us &amp;lt;&amp;lt; RADIO_DFECTRL1_TSAMPLESPACINGREF_Pos |
                              RADIO_DFECTRL1_TSAMPLESPACING_1us   &amp;lt;&amp;lt; RADIO_DFECTRL1_TSAMPLESPACING_Pos |
                              RADIO_DFECTRL1_TSWITCHSPACING_1us     &amp;lt;&amp;lt; RADIO_DFECTRL1_TSWITCHSPACING_Pos |
                              RADIO_DFECTRL1_SAMPLETYPE_MagPhase    &amp;lt;&amp;lt; RADIO_DFECTRL1_SAMPLETYPE_Pos;
    
    // I don&amp;#39;t kwow which offsets I should put there
    NRF_RADIO-&amp;gt;DFECTRL2 = 0 &amp;lt;&amp;lt; RADIO_DFECTRL2_TSWITCHOFFSET_Pos |
                          0 &amp;lt;&amp;lt; RADIO_DFECTRL2_TSAMPLEOFFSET_Pos;
    
    NRF_RADIO-&amp;gt;PSEL.DFEGPIO[0] = 0x00000016; // (P0.22) - RF switch control pin
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // before CTE - antenna 1
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // reference - antenna 1
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // slots 0, 2, 4... - antenna 1 switching
    // NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // slots 0, 2, 4... - antenna 1 sampling
    // NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x1; // slots 1, 3, 5... - antenna 2 switching
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x1; // slots 1, 3, 5... - antenna 2 sampling&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;3. I expect that in this configuration, switching between antennas will occur after each sample.&amp;nbsp;I have received the following phase graphs (0-45-90 degrees):&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_20-_3204_-18.33.00.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Something still seems wrong...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/250581?ContentTypeID=1</link><pubDate>Tue, 19 May 2020 07:06:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e796c91d-1aec-4e67-a3ba-4073e60cf5c1</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Have you actually looked at P0.22 using a scope or logic analyzer to see if it is toggling or not?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/250381?ContentTypeID=1</link><pubDate>Mon, 18 May 2020 08:43:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:087fbd9f-d90a-45cb-87a0-cbacf1d7fc99</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;At the moment, I found out that there are problems with the antenna switch and with the external antenna. As soon as I eliminate them, I will continue to try&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/250063?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 21:05:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39315252-c8ba-491b-988a-4b5126a777af</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;You didn&amp;#39;t enabled CRC. I don&amp;#39;t know whether DFE&amp;nbsp;can start without CRC if you configure&amp;nbsp;RADIO_DFECTRL1_DFEINEXTENSION_CRC.&lt;/p&gt;
[quote userid="90254" url="~/f/nordic-q-a/61296/configure-radio-at-nrf52811-for-antenna-switching/250047"]larger array (2048 val.)[/quote]
&lt;p&gt;a sample is two 16-bit values, you need 4096&amp;nbsp;16-bit cells. MAXCNT is in samples units (2048 is right).&lt;/p&gt;
[quote userid="90254" url="~/f/nordic-q-a/61296/configure-radio-at-nrf52811-for-antenna-switching/250047"]What about&amp;nbsp; DFECTRL2 and&amp;nbsp;SWITCHPATTERN? Maybe I configure them wrong?[/quote]
&lt;p&gt;&lt;span&gt;SWITCHPATTERN seems to be correct&lt;/span&gt;. Do you have an ocsilloscope to&amp;nbsp;look at P0.22 - is any switching takes place? Also you can try to configure &lt;span class="pl-en"&gt;RADIO_DFECTRL1_DFEINEXTENSION_Payload&lt;/span&gt;&lt;span&gt;&amp;nbsp;at receiver side&amp;nbsp;&lt;/span&gt;to catch your payload as I/Q samples - you should see up/down slope for bits 0/1.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/250047?ContentTypeID=1</link><pubDate>Thu, 14 May 2020 18:16:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d625e496-de0a-4aff-961b-e91e3c0853d0</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;So, I did:&lt;/p&gt;
&lt;p&gt;1. larger array (2048 val.)&lt;/p&gt;
&lt;p&gt;2. set&amp;nbsp;&lt;span&gt;DFEPACKET.MAXCNT = 2048&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;3.&amp;nbsp;TSAMPLESPACING ==&amp;nbsp;TSAMPLESPACINGREF =&amp;nbsp;&lt;/span&gt;125ns&lt;/p&gt;
&lt;p&gt;4 . different. setting for receiver and transmitter&lt;/p&gt;
&lt;p&gt;5 . DFECTRL2 = 0 for now (don&amp;#39;t know which offsets i should put there)&lt;/p&gt;
&lt;p&gt;6. delete loop: &amp;quot;while (NRF_RADIO-&amp;gt;EVENTS_PHYEND == 0U)&amp;quot;&lt;/p&gt;
&lt;p&gt;7. Add &amp;quot;packet&amp;quot; to validate received info.&lt;/p&gt;
&lt;p&gt;Here my full code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#ifndef RECEIVER
#define RECEIVER    1
#define TRANSMITTER !RECEIVER
#endif
#define MAXCNT1 2048
uint32_t packet = 0;              /**&amp;lt; Packet to transmit. */
int16_t i_q1[MAXCNT1];

/**@brief Function for initialization oscillators.
 */
void clock_initialization()
{
    /* Start 16 MHz crystal oscillator */
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART    = 1;

    /* Wait for the external oscillator to start up */
    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
    {
        // Do nothing.
    }

    /* Start low frequency crystal oscillator for app_timer(used by bsp)*/
    NRF_CLOCK-&amp;gt;LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_RC &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos);
    NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART    = 1;

    while (NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0)
    {
        // Do nothing.
    }
}

/**@brief Function for sending packet.
 */
uint32_t send_packet(unsigned long freq, uint16_t *i_q)
{
    // send the packet:
    uint32_t result = 0;

    NRF_RADIO-&amp;gt;FREQUENCY = freq;
    // NRF_RADIO-&amp;gt;DFEPACKET.PTR = i_q;
    NRF_RADIO-&amp;gt;EVENTS_READY = 0U;
    NRF_RADIO-&amp;gt;TASKS_TXEN   = 1;
    int a = 0;

    while (NRF_RADIO-&amp;gt;EVENTS_READY == 0U) {}
    NRF_RADIO-&amp;gt;EVENTS_END  = 0U;
    NRF_RADIO-&amp;gt;TASKS_START = 1U;

    while (NRF_RADIO-&amp;gt;EVENTS_END == 0U) {}
    nrf_delay_ms(50);

    NRF_RADIO-&amp;gt;EVENTS_DISABLED = 0U;
    NRF_RADIO-&amp;gt;EVENTS_PHYEND = 0U;
    // Disable radio
    NRF_RADIO-&amp;gt;TASKS_DISABLE = 1U;
    while (NRF_RADIO-&amp;gt;EVENTS_DISABLED == 0U) {}
    return result;
}

/**@brief Function for reading packet.
 */
uint32_t read_packet(unsigned long freq, uint16_t *i_q)
{
    uint32_t result = 0;
    int a = 0;

    NRF_RADIO-&amp;gt;FREQUENCY = freq;
    NRF_RADIO-&amp;gt;DFEPACKET.PTR = i_q;
    NRF_RADIO-&amp;gt;DFEPACKET.MAXCNT = MAXCNT1;
    NRF_RADIO-&amp;gt;EVENTS_READY = 0U;
    // Enable radio and wait for ready
    NRF_RADIO-&amp;gt;TASKS_RXEN = 1U;

    while (NRF_RADIO-&amp;gt;EVENTS_READY == 0U) {}
    NRF_RADIO-&amp;gt;EVENTS_END = 0U;
    // Start listening and wait for address received event
    NRF_RADIO-&amp;gt;TASKS_START = 1U;
    
    while (NRF_RADIO-&amp;gt;EVENTS_END == 0U) {}
    nrf_delay_ms(100);

    if (NRF_RADIO-&amp;gt;CRCSTATUS == 1U)
        result = packet;
    NRF_RADIO-&amp;gt;EVENTS_DISABLED = 0U;
    NRF_RADIO-&amp;gt;EVENTS_PHYEND = 0U;
    
    // Disable radio
    NRF_RADIO-&amp;gt;TASKS_DISABLE = 1U;
    while (NRF_RADIO-&amp;gt;EVENTS_DISABLED == 0U) {}
    return result;
}

static void print_logs()
{
    LOG_DBG(&amp;quot;%d&amp;quot;, packet);
    for (int i = 0; i &amp;lt; MAXCNT1; i++)
            if (!(i % 2)) //print only 1,3,5 ... - phases
                LOG_DBG(&amp;quot; %d&amp;quot;, i_q1[i]);
    nrf_delay_ms(10); // to print all values we should wait a little
    LOG_DBG(&amp;quot;\n&amp;quot;);
    nrf_delay_ms(10);
}

/**
 * @brief Function for application main entry.
 * @return 0. int return type required by ANSI/ISO standard.
 */
int main(void)
{
    uint32_t err_code = NRF_SUCCESS;

    clock_initialization();
    // timer_init();

    // Set radio configuration parameters
    nrf_gpio_cfg_output(0x00000016); // (P0.22) - RF switch control pin - set as output prior
    radio_configure();
    NRF_RADIO-&amp;gt;PACKETPTR = (uint32_t)&amp;amp;packet;


    LOG_DBG(&amp;quot;Radio example started.\n&amp;quot;);

    while (true)
    {
        #if RECEIVER
        read_packet(16UL, i_q1);
        print_logs();
        #else
        if (packet != 0)
        {
            send_packet(16UL, i_q1); // send at (2416MHz)
            LOG_DBG(&amp;quot;Send %d!\n&amp;quot;, packet);
            // packet = 0;
        }
        nrf_delay_ms(500);
        packet++;
        // __WFE();
        #endif
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void radio_configure()
{
    // Radio config
    NRF_RADIO-&amp;gt;TXPOWER   = (RADIO_TXPOWER_TXPOWER_Pos4dBm/*RADIO_TXPOWER_TXPOWER_0dBm*/ &amp;lt;&amp;lt; RADIO_TXPOWER_TXPOWER_Pos);
    NRF_RADIO-&amp;gt;FREQUENCY = 16UL;
    NRF_RADIO-&amp;gt;MODE      = (RADIO_MODE_MODE_Ble_2Mbit/*RADIO_MODE_MODE_Nrf_1Mbit*/ &amp;lt;&amp;lt; RADIO_MODE_MODE_Pos);

    // Radio address config
    NRF_RADIO-&amp;gt;PREFIX0 =
        ((uint32_t)swap_bits(0xC3) &amp;lt;&amp;lt; 24) // Prefix byte of address 3 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC2) &amp;lt;&amp;lt; 16) // Prefix byte of address 2 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC1) &amp;lt;&amp;lt; 8)  // Prefix byte of address 1 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC0) &amp;lt;&amp;lt; 0); // Prefix byte of address 0 converted to nRF24L series format

    NRF_RADIO-&amp;gt;PREFIX1 =
        ((uint32_t)swap_bits(0xC7) &amp;lt;&amp;lt; 24) // Prefix byte of address 7 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC6) &amp;lt;&amp;lt; 16) // Prefix byte of address 6 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC4) &amp;lt;&amp;lt; 0); // Prefix byte of address 4 converted to nRF24L series format

    NRF_RADIO-&amp;gt;BASE0 = bytewise_bitswap(0x01234567UL);  // Base address for prefix 0 converted to nRF24L series format
    NRF_RADIO-&amp;gt;BASE1 = bytewise_bitswap(0x89ABCDEFUL);  // Base address for prefix 1-7 converted to nRF24L series format

    NRF_RADIO-&amp;gt;TXADDRESS   = 0x00UL;  // Set device address 0 to use when transmitting
    NRF_RADIO-&amp;gt;RXADDRESSES = 0x01UL;  // Enable device address 0 to use to select which addresses to receive

    // Packet configuration
    NRF_RADIO-&amp;gt;PCNF0 = (PACKET_S1_FIELD_SIZE     &amp;lt;&amp;lt; RADIO_PCNF0_S1LEN_Pos) |
                       (PACKET_S0_FIELD_SIZE     &amp;lt;&amp;lt; RADIO_PCNF0_S0LEN_Pos) |
                       (PACKET_LENGTH_FIELD_SIZE &amp;lt;&amp;lt; RADIO_PCNF0_LFLEN_Pos); //lint !e845 &amp;quot;The right argument to operator &amp;#39;|&amp;#39; is certain to be 0&amp;quot;

    // Packet configuration
    NRF_RADIO-&amp;gt;PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled &amp;lt;&amp;lt; RADIO_PCNF1_WHITEEN_Pos) |
                       (RADIO_PCNF1_ENDIAN_Big       &amp;lt;&amp;lt; RADIO_PCNF1_ENDIAN_Pos)  |
                       (PACKET_BASE_ADDRESS_LENGTH   &amp;lt;&amp;lt; RADIO_PCNF1_BALEN_Pos)   |
                       (PACKET_STATIC_LENGTH         &amp;lt;&amp;lt; RADIO_PCNF1_STATLEN_Pos) |
                       (PACKET_PAYLOAD_MAXSIZE       &amp;lt;&amp;lt; RADIO_PCNF1_MAXLEN_Pos); //lint !e845 &amp;quot;The right argument to operator &amp;#39;|&amp;#39; is certain to be 0&amp;quot;

    // CRC Config
    //NRF_RADIO-&amp;gt;CRCCNF = (RADIO_CRCCNF_LEN_Two &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos); // Number of checksum bits
    NRF_RADIO-&amp;gt;CRCCNF = (RADIO_CRCCNF_LEN_Disabled &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos);
    if ((NRF_RADIO-&amp;gt;CRCCNF &amp;amp; RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_Two &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO-&amp;gt;CRCINIT = 0xFFFFUL;   // Initial value
        NRF_RADIO-&amp;gt;CRCPOLY = 0x11021UL;  // CRC poly: x^16 + x^12^x^5 + 1
    }
    else if ((NRF_RADIO-&amp;gt;CRCCNF &amp;amp; RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_One &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO-&amp;gt;CRCINIT = 0xFFUL;   // Initial value
        NRF_RADIO-&amp;gt;CRCPOLY = 0x107UL;  // CRC poly: x^8 + x^2^x^1 + 1
    }

    NRF_RADIO-&amp;gt;MODECNF0 = RADIO_MODECNF0_RU_Fast &amp;lt;&amp;lt; RADIO_MODECNF0_RU_Pos |
                         RADIO_MODECNF0_DTX_Center &amp;lt;&amp;lt; RADIO_MODECNF0_DTX_Pos;
    NRF_RADIO-&amp;gt;DFEMODE = RADIO_DFEMODE_DFEOPMODE_AoA;

#if RECEIVER
    NRF_RADIO-&amp;gt;DFECTRL1 =     31                                    &amp;lt;&amp;lt; RADIO_DFECTRL1_NUMBEROF8US_Pos |
                              RADIO_DFECTRL1_DFEINEXTENSION_CRC     &amp;lt;&amp;lt; RADIO_DFECTRL1_DFEINEXTENSION_Pos |
                              RADIO_DFECTRL1_TSAMPLESPACINGREF_125ns &amp;lt;&amp;lt; RADIO_DFECTRL1_TSAMPLESPACINGREF_Pos |
                              RADIO_DFECTRL1_TSAMPLESPACING_125ns   &amp;lt;&amp;lt; RADIO_DFECTRL1_TSAMPLESPACING_Pos |
                              RADIO_DFECTRL1_TSWITCHSPACING_1us     &amp;lt;&amp;lt; RADIO_DFECTRL1_TSWITCHSPACING_Pos |
                              RADIO_DFECTRL1_SAMPLETYPE_MagPhase    &amp;lt;&amp;lt; RADIO_DFECTRL1_SAMPLETYPE_Pos;
    
    // I don&amp;#39;t kwow which offsets I should put there
    NRF_RADIO-&amp;gt;DFECTRL2 = 0 &amp;lt;&amp;lt; RADIO_DFECTRL2_TSWITCHOFFSET_Pos |
                          0 &amp;lt;&amp;lt; RADIO_DFECTRL2_TSAMPLEOFFSET_Pos;
    
    NRF_RADIO-&amp;gt;PSEL.DFEGPIO[0] = 0x00000016; // (P0.22) - RF switch control pin
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // before CTE - antenna 1
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // reference - antenna 1
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // slots 0, 2, 4... - antenna 1 switching
    // NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // slots 0, 2, 4... - antenna 1 sampling
    // NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x1; // slots 1, 3, 5... - antenna 2 switching
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x1; // slots 1, 3, 5... - antenna 2 sampling

#else
    NRF_RADIO-&amp;gt;DFECTRL1 =     31                                    &amp;lt;&amp;lt; RADIO_DFECTRL1_NUMBEROF8US_Pos |
                              RADIO_DFECTRL1_DFEINEXTENSION_CRC     &amp;lt;&amp;lt; RADIO_DFECTRL1_DFEINEXTENSION_Pos;
#endif

    //NRF_RADIO-&amp;gt;CTEINLINECONF = RADIO_CTEINLINECONF_S0MASK_Msk;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Also I got I/Q data in MagPhase format and built graphs for different&amp;nbsp;angles. And it&amp;#39;s still seems like it doesn&amp;#39;t switch correctly:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_14-_3204_-20.57.32.png" /&gt;&lt;/p&gt;
&lt;p&gt;What about&amp;nbsp; DFECTRL2 and&amp;nbsp;SWITCHPATTERN? Maybe I configure them wrong?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249796?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 16:00:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e48886e1-dfc2-4669-bef9-9875b11b077a</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;1) your i_q array is too small - for 31*8 usec, even with 4-usec sampling, you will get (2+31*2)*4=256 bytes. Also it&amp;#39;s safer to set DFEPACKET.MAXCNT to the maximum number of samples your array can hold.&lt;/p&gt;
&lt;p&gt;2) you need to configure PACKETPTR and allocate a&amp;nbsp;memory&amp;nbsp;for it, even if you don&amp;#39;t expect any bytes to exchange. I would create some small payload with CRC, thus you can check at receiver side that&amp;nbsp;packet is received correctly and you can trust AoA samples. (there is another point - you&amp;#39;re configuring DFE after CRC event, how it will work when CRC is disabled?)&lt;/p&gt;
&lt;p&gt;3) leave&amp;nbsp;&lt;span&gt;TSAMPLESPACING with some documented value, nobody can tell what&amp;#39;s happen when&amp;nbsp;it&amp;#39;s zeroed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;4) I would not rely on&amp;nbsp;PHYEND at receiver side as it&amp;#39;s not documented. For now, just add nrf_delay_us() after getting END event to wait while all samples are received.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249773?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 14:17:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:55513345-3b8c-4b42-8d40-ef426e869613</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;What values should I put in&amp;nbsp;&lt;span&gt;DFECTRL2 and&amp;nbsp;DFEPACKET.MAXCNT?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Thanks&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249770?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 14:11:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:76bcfc74-d1da-49c5-a014-7b87b993a9be</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;Hi, yes, I&amp;#39;m tried&amp;nbsp;&lt;span&gt;an equal number for&amp;nbsp;TSWITCHSPACING and&amp;nbsp;TSAMPLESPACING. But in this case no packets at all was received.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249769?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 14:08:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d7105e18-dc49-465f-824b-cc65e690ff5a</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;Hi. There is full config code:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;quot;radio_config.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;

#define RECEIVER    1
#define TRANSMITTER !RECEIVER

/* These are set to zero as ShockBurst packets don&amp;#39;t have corresponding fields. */
#define PACKET_S1_FIELD_SIZE      (0UL)  /**&amp;lt; Packet S1 field size in bits. */
#define PACKET_S0_FIELD_SIZE      (0UL)  /**&amp;lt; Packet S0 field size in bits. */
#define PACKET_LENGTH_FIELD_SIZE  (0UL)  /**&amp;lt; Packet length field size in bits. */

/**
 * @brief Function for swapping/mirroring bits in a byte.
 *
 *@verbatim
 * output_bit_7 = input_bit_0
 * output_bit_6 = input_bit_1
 *           :
 * output_bit_0 = input_bit_7
 *@endverbatim
 *
 * @param[in] inp is the input byte to be swapped.
 *
 * @return
 * Returns the swapped/mirrored input byte.
 */
static uint32_t swap_bits(uint32_t inp);

/**
 * @brief Function for swapping bits in a 32 bit word for each byte individually.
 *
 * The bits are swapped as follows:
 * @verbatim
 * output[31:24] = input[24:31]
 * output[23:16] = input[16:23]
 * output[15:8]  = input[8:15]
 * output[7:0]   = input[0:7]
 * @endverbatim
 * @param[in] input is the input word to be swapped.
 *
 * @return
 * Returns the swapped input byte.
 */
static uint32_t bytewise_bitswap(uint32_t inp);

static uint32_t swap_bits(uint32_t inp)
{
    uint32_t i;
    uint32_t retval = 0;

    inp = (inp &amp;amp; 0x000000FFUL);

    for (i = 0; i &amp;lt; 8; i++)
    {
        retval |= ((inp &amp;gt;&amp;gt; i) &amp;amp; 0x01) &amp;lt;&amp;lt; (7 - i);
    }

    return retval;
}


static uint32_t bytewise_bitswap(uint32_t inp)
{
      return (swap_bits(inp &amp;gt;&amp;gt; 24) &amp;lt;&amp;lt; 24)
           | (swap_bits(inp &amp;gt;&amp;gt; 16) &amp;lt;&amp;lt; 16)
           | (swap_bits(inp &amp;gt;&amp;gt; 8) &amp;lt;&amp;lt; 8)
           | (swap_bits(inp));
}


/**
 * @brief Function for configuring the radio to operate in ShockBurst compatible mode.
 *
 * To configure the application running on nRF24L series devices:
 *
 * @verbatim
 * uint8_t tx_address[5] = { 0xC0, 0x01, 0x23, 0x45, 0x67 };
 * hal_nrf_set_rf_channel(7);
 * hal_nrf_set_address_width(HAL_NRF_AW_5BYTES);
 * hal_nrf_set_address(HAL_NRF_TX, tx_address);
 * hal_nrf_set_address(HAL_NRF_PIPE0, tx_address);
 * hal_nrf_open_pipe(0, false);
 * hal_nrf_set_datarate(HAL_NRF_1MBPS);
 * hal_nrf_set_crc_mode(HAL_NRF_CRC_16BIT);
 * hal_nrf_setup_dynamic_payload(0xFF);
 * hal_nrf_enable_dynamic_payload(false);
 * @endverbatim
 *
 * When transmitting packets with hal_nrf_write_tx_payload(const uint8_t *tx_pload, uint8_t length),
 * match the length with PACKET_STATIC_LENGTH.
 * hal_nrf_write_tx_payload(payload, PACKET_STATIC_LENGTH);
 *
*/
void radio_configure()
{
    // Radio config
    NRF_RADIO-&amp;gt;TXPOWER   = (RADIO_TXPOWER_TXPOWER_Pos4dBm/*RADIO_TXPOWER_TXPOWER_0dBm*/ &amp;lt;&amp;lt; RADIO_TXPOWER_TXPOWER_Pos);
    NRF_RADIO-&amp;gt;FREQUENCY = 16UL;
    NRF_RADIO-&amp;gt;MODE      = (RADIO_MODE_MODE_Ble_2Mbit/*RADIO_MODE_MODE_Nrf_1Mbit*/ &amp;lt;&amp;lt; RADIO_MODE_MODE_Pos);

    // Radio address config
    NRF_RADIO-&amp;gt;PREFIX0 =
        ((uint32_t)swap_bits(0xC3) &amp;lt;&amp;lt; 24) // Prefix byte of address 3 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC2) &amp;lt;&amp;lt; 16) // Prefix byte of address 2 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC1) &amp;lt;&amp;lt; 8)  // Prefix byte of address 1 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC0) &amp;lt;&amp;lt; 0); // Prefix byte of address 0 converted to nRF24L series format

    NRF_RADIO-&amp;gt;PREFIX1 =
        ((uint32_t)swap_bits(0xC7) &amp;lt;&amp;lt; 24) // Prefix byte of address 7 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC6) &amp;lt;&amp;lt; 16) // Prefix byte of address 6 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC4) &amp;lt;&amp;lt; 0); // Prefix byte of address 4 converted to nRF24L series format

    NRF_RADIO-&amp;gt;BASE0 = bytewise_bitswap(0x01234567UL);  // Base address for prefix 0 converted to nRF24L series format
    NRF_RADIO-&amp;gt;BASE1 = bytewise_bitswap(0x89ABCDEFUL);  // Base address for prefix 1-7 converted to nRF24L series format

    NRF_RADIO-&amp;gt;TXADDRESS   = 0x00UL;  // Set device address 0 to use when transmitting
    NRF_RADIO-&amp;gt;RXADDRESSES = 0x01UL;  // Enable device address 0 to use to select which addresses to receive

    // Packet configuration
    NRF_RADIO-&amp;gt;PCNF0 = (PACKET_S1_FIELD_SIZE     &amp;lt;&amp;lt; RADIO_PCNF0_S1LEN_Pos) |
                       (PACKET_S0_FIELD_SIZE     &amp;lt;&amp;lt; RADIO_PCNF0_S0LEN_Pos) |
                       (PACKET_LENGTH_FIELD_SIZE &amp;lt;&amp;lt; RADIO_PCNF0_LFLEN_Pos); //lint !e845 &amp;quot;The right argument to operator &amp;#39;|&amp;#39; is certain to be 0&amp;quot;

    // Packet configuration
    NRF_RADIO-&amp;gt;PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled &amp;lt;&amp;lt; RADIO_PCNF1_WHITEEN_Pos) |
                       (RADIO_PCNF1_ENDIAN_Big       &amp;lt;&amp;lt; RADIO_PCNF1_ENDIAN_Pos)  |
                       (PACKET_BASE_ADDRESS_LENGTH   &amp;lt;&amp;lt; RADIO_PCNF1_BALEN_Pos)   |
                       (PACKET_STATIC_LENGTH         &amp;lt;&amp;lt; RADIO_PCNF1_STATLEN_Pos) |
                       (PACKET_PAYLOAD_MAXSIZE       &amp;lt;&amp;lt; RADIO_PCNF1_MAXLEN_Pos); //lint !e845 &amp;quot;The right argument to operator &amp;#39;|&amp;#39; is certain to be 0&amp;quot;

    // CRC Config
    //NRF_RADIO-&amp;gt;CRCCNF = (RADIO_CRCCNF_LEN_Two &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos); // Number of checksum bits
    NRF_RADIO-&amp;gt;CRCCNF = (RADIO_CRCCNF_LEN_Disabled &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos);
    if ((NRF_RADIO-&amp;gt;CRCCNF &amp;amp; RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_Two &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO-&amp;gt;CRCINIT = 0xFFFFUL;   // Initial value
        NRF_RADIO-&amp;gt;CRCPOLY = 0x11021UL;  // CRC poly: x^16 + x^12^x^5 + 1
    }
    else if ((NRF_RADIO-&amp;gt;CRCCNF &amp;amp; RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_One &amp;lt;&amp;lt; RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO-&amp;gt;CRCINIT = 0xFFUL;   // Initial value
        NRF_RADIO-&amp;gt;CRCPOLY = 0x107UL;  // CRC poly: x^8 + x^2^x^1 + 1
    }

    NRF_RADIO-&amp;gt;MODECNF0 = RADIO_MODECNF0_RU_Fast &amp;lt;&amp;lt; RADIO_MODECNF0_RU_Pos |
                         RADIO_MODECNF0_DTX_Center &amp;lt;&amp;lt; RADIO_MODECNF0_DTX_Pos;
    NRF_RADIO-&amp;gt;DFEMODE = RADIO_DFEMODE_DFEOPMODE_AoA;

    #if RECEIVER
    NRF_RADIO-&amp;gt;DFECTRL1 =     31                                    &amp;lt;&amp;lt; RADIO_DFECTRL1_NUMBEROF8US_Pos |
                              RADIO_DFECTRL1_DFEINEXTENSION_CRC     &amp;lt;&amp;lt; RADIO_DFECTRL1_DFEINEXTENSION_Pos |
                              RADIO_DFECTRL1_TSAMPLESPACINGREF_4us &amp;lt;&amp;lt; RADIO_DFECTRL1_TSAMPLESPACINGREF_Pos |
                            //   RADIO_DFECTRL1_TSAMPLESPACING_4us   &amp;lt;&amp;lt; RADIO_DFECTRL1_TSAMPLESPACING_Pos |
                              RADIO_DFECTRL1_TSWITCHSPACING_1us     &amp;lt;&amp;lt; RADIO_DFECTRL1_TSWITCHSPACING_Pos |
                              RADIO_DFECTRL1_SAMPLETYPE_MagPhase    &amp;lt;&amp;lt; RADIO_DFECTRL1_SAMPLETYPE_Pos;
                              
    
    NRF_RADIO-&amp;gt;PSEL.DFEGPIO[0] = 0x00000016; // (P0.22) - RF switch control pin
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // before CTE - antenna 1
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // reference - antenna 1
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // slots 0, 2, 4... - antenna 1 switching
    // NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x0; // slots 0, 2, 4... - antenna 1 sampling
    // NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x1; // slots 1, 3, 5... - antenna 2 switching
    NRF_RADIO-&amp;gt;SWITCHPATTERN = 0x1; // slots 1, 3, 5... - antenna 2 sampling

    #else
    NRF_RADIO-&amp;gt;DFECTRL1 =     31                                    &amp;lt;&amp;lt; RADIO_DFECTRL1_NUMBEROF8US_Pos |
                              RADIO_DFECTRL1_DFEINEXTENSION_CRC     &amp;lt;&amp;lt; RADIO_DFECTRL1_DFEINEXTENSION_Pos;
    #endif

    //NRF_RADIO-&amp;gt;CTEINLINECONF = RADIO_CTEINLINECONF_S0MASK_Msk;
}
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;main (main parts of it):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;int16_t i_q1[62];

/**@brief Function for initialization oscillators.
 */
void clock_initialization()
{
    /* Start 16 MHz crystal oscillator */
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART    = 1;

    /* Wait for the external oscillator to start up */
    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0)
    {
        // Do nothing.
    }

    /* Start low frequency crystal oscillator for app_timer(used by bsp)*/
    NRF_CLOCK-&amp;gt;LFCLKSRC            = (CLOCK_LFCLKSRC_SRC_RC &amp;lt;&amp;lt; CLOCK_LFCLKSRC_SRC_Pos);
    NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_LFCLKSTART    = 1;

    while (NRF_CLOCK-&amp;gt;EVENTS_LFCLKSTARTED == 0)
    {
        // Do nothing.
    }
}

/**@brief Function for sending packet.
 */
uint32_t send_packet(unsigned long freq, uint16_t *i_q)
{
    // send the packet:
    uint32_t result = 0;

    NRF_RADIO-&amp;gt;FREQUENCY = freq;
    NRF_RADIO-&amp;gt;DFEPACKET.PTR = i_q;
    NRF_RADIO-&amp;gt;EVENTS_READY = 0U;
    NRF_RADIO-&amp;gt;TASKS_TXEN   = 1;
    int a = 0;

    while (NRF_RADIO-&amp;gt;EVENTS_READY == 0U) {}
    NRF_RADIO-&amp;gt;EVENTS_END  = 0U;
    NRF_RADIO-&amp;gt;TASKS_START = 1U;

    while (NRF_RADIO-&amp;gt;EVENTS_PHYEND == 0U)
    {
        while (NRF_RADIO-&amp;gt;EVENTS_END == 0U) {}
    }

    NRF_RADIO-&amp;gt;EVENTS_DISABLED = 0U;
    NRF_RADIO-&amp;gt;EVENTS_PHYEND = 0U;
    // Disable radio
    NRF_RADIO-&amp;gt;TASKS_DISABLE = 1U;
    while (NRF_RADIO-&amp;gt;EVENTS_DISABLED == 0U) {}
    return result;
}

/**@brief Function for reading packet.
 */
uint32_t read_packet(unsigned long freq, uint16_t *i_q)
{
    uint32_t result = 0;
    int a = 0;

    NRF_RADIO-&amp;gt;FREQUENCY = freq;
    NRF_RADIO-&amp;gt;DFEPACKET.PTR = i_q;
    NRF_RADIO-&amp;gt;EVENTS_READY = 0U;
    // Enable radio and wait for ready
    NRF_RADIO-&amp;gt;TASKS_RXEN = 1U;

    while (NRF_RADIO-&amp;gt;EVENTS_READY == 0U) {}
    NRF_RADIO-&amp;gt;EVENTS_END = 0U;
    // Start listening and wait for address received event
    NRF_RADIO-&amp;gt;TASKS_START = 1U;
    
    // Wait for end of packet or buttons state changed
    while (NRF_RADIO-&amp;gt;EVENTS_PHYEND == 0U)
    {
        while (NRF_RADIO-&amp;gt;EVENTS_END == 0U) {}
    }
    NRF_RADIO-&amp;gt;EVENTS_DISABLED = 0U;
    NRF_RADIO-&amp;gt;EVENTS_PHYEND = 0U;
    
    // Disable radio
    NRF_RADIO-&amp;gt;TASKS_DISABLE = 1U;
    while (NRF_RADIO-&amp;gt;EVENTS_DISABLED == 0U) {}
    return result;
}

int main(void)
{
    uint32_t err_code = NRF_SUCCESS;

    clock_initialization();

    // Set radio configuration parameters
    nrf_gpio_cfg_output(0x00000016); // (P0.22) - RF switch control pin - set as output prior
    radio_configure();
    NRF_RADIO-&amp;gt;PACKETPTR = (uint32_t)&amp;amp;packet;

    LOG_DBG(&amp;quot;Radio example started.\n&amp;quot;);

    while (true)
    {
        #if RECEIVER
        read_packet(16UL, i_q1);
        print_logs(1, 2, 3);
        #else
        if (packet != 0)
        {
            send_packet(16UL, i_q1); // send at (2416MHz)\
            packet = 0;
        }
        nrf_delay_ms(500);
        packet++;
        #endif
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249699?ContentTypeID=1</link><pubDate>Wed, 13 May 2020 11:40:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:68bc08d6-457d-42a6-bd96-6b2b298dc4d1</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;TSWITCHSPACING indicates the time between the switch slots and TSAMPLESPACING indicates the time between samples. Have you tried using an equal number for these?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249555?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 17:11:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3face92e-d627-425a-b44b-f6db27b98ec8</guid><dc:creator>Pete W</dc:creator><description>&lt;p&gt;PHYEND does seem to be generated in Rx mode. It&amp;#39;s just not shown in the nRF52811 product spec. It is shown in the nRF52833 PS. If you use END to disable you might truncate your samples.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249513?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 14:06:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:00255cac-c0a7-4841-a6a9-08568540ae87</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;Did you set other registers correctly? DFECTRL2, DFEPACKET.PTR, &lt;span&gt;DFEPACKET.MAXCNT&lt;/span&gt;? It would be much better to look at the whole&amp;nbsp;radio configuration code, not just some screenshots. Also, I&amp;#39;m not sure that PHYEND is fired in receiver mode - at least, spec doesn&amp;#39;t say anything about PHYEND for receive sequence.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249491?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 13:12:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6dee2a5a-653e-4df3-83bc-aab65df174d0</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;So, about settings for&amp;nbsp;&lt;span&gt;TSAMPLESPACINGREF and&amp;nbsp;TSAMPLESPACING: I tried many combinations and it worcs only with&amp;nbsp;TSAMPLESPACINGREF ==&amp;nbsp;&lt;/span&gt;RADIO_DFECTRL1_TSAMPLESPACINGREF_4us and&amp;nbsp;&lt;span&gt;TSAMPLESPACING == 0 (not set at all). Some results with this configuration:&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_12-_3204_-16.06.11.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;For Phases samples at different degrees:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_12-_3204_-16.08.00.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;(0 degrees means that all 3 antennas placed on one line)&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Just for sure, there the same pictures with&amp;nbsp;TSAMPLESPACINGREF == 0:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_12-_3204_-16.10.28.png" /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What am I missing?&amp;nbsp;I do not see an adequate phase shift, which could be associated with an angle...&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249470?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 12:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f84b4e99-0445-46b9-9d1e-ad2ea27c0313</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;The same result if I configure receiver and transmitter differently:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_12-_3204_-15.32.21.png" /&gt;&lt;/p&gt;
&lt;p&gt;Only&amp;nbsp;&lt;span&gt;NUMBEROF8US and DFEINEXTENSION for DFECTRL1 on the transmitter was configured. But receiver couldn&amp;#39;t receive data any more with this configuration&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249455?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 12:10:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d450e0b-48ed-4ccb-a620-2ef9856ea390</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;When I change config in both receiver and transmitter to this:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_12-_3204_-15.06.00.png" /&gt;&lt;/p&gt;
&lt;p&gt;the receiver stopped receiving any packets, the program freezes on this line (added a loop to control the sending / receiving of CTE information):&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/_21043D0438043C043E043A04_-_4D043A04400430043D043004_-2020_2D00_05_2D00_12-_3204_-15.05.40.png" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249450?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 12:01:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c8b8cc11-871a-4125-acba-ab246f68edeb</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;Should the radio configuration for the receiver and transmitter be the same? Or is it enough to configure NUMBEROF8US and DFEINEXTENSION for DFECTRL1 on the transmitter?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249420?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 11:34:45 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0af27958-db99-4bd0-9a75-906d340103be</guid><dc:creator>Andreas</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When configuring antenna switching, each write to SWITCHPATTERN applies to the switch slot and sample slot. This probably means that sample 0,1,4,5,8,9,.... are done using antenna 1, and slot 2,3,6,7,10,11 are done using antenna 2.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Also remember that you need to configure the GPIOs as output prior to starting the radio.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249413?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 11:24:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e299e9d4-5f25-430a-af81-1eac473446a7</guid><dc:creator>Dmitry</dc:creator><description>&lt;p&gt;You didn&amp;#39;t set&amp;nbsp;TSAMPLESPACINGREF and&amp;nbsp;TSAMPLESPACING - according to spec, valid values are 1-6 but not 0. With maximum oversampling (0.125us) you will see more detailed graph.&lt;/p&gt;
[quote userid="90254" url="~/f/nordic-q-a/61296/configure-radio-at-nrf52811-for-antenna-switching"]And what should we get when working with frames?[/quote]
&lt;p&gt;I couldn&amp;#39;t get what you mean under &amp;quot;frames&amp;quot;. When CTE starts, transmitter emits a clean wave at&amp;nbsp;Fcarrier+250kHz. Demodulator multiplies it by two &lt;span&gt;Fcarrier&amp;nbsp;&lt;/span&gt;signals shifted by 90 degrees to get I and Q channels, the result is a complex signal at ~250kHz and phase difference corresponds to the one of RF signal (an impact of crystal inaccuracy is noticeable, in practice you can get 150-350kHz). The method of getting angle from phase offset is the same, except that you should take frequency offset into account.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Configure radio at NRF52811 for antenna switching</title><link>https://devzone.nordicsemi.com/thread/249399?ContentTypeID=1</link><pubDate>Tue, 12 May 2020 10:07:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64042f1a-2646-4dba-b370-6a5af2454a46</guid><dc:creator>AlexVrubel</dc:creator><description>&lt;p&gt;&lt;a href="https://drive.google.com/open?id=1BSDEHPcr-foPAZTwwjkWRdNskFHV_SFP"&gt;https://drive.google.com/open?id=1BSDEHPcr-foPAZTwwjkWRdNskFHV_SFP&lt;/a&gt;&amp;nbsp;- configuration&lt;/p&gt;
&lt;p&gt;&lt;a href="https://drive.google.com/open?id=1u0LocDyuQ8vd2_2xNj7shOGuKUNyPiKj"&gt;https://drive.google.com/open?id=1u0LocDyuQ8vd2_2xNj7shOGuKUNyPiKj&lt;/a&gt;&amp;nbsp;- phases i&amp;#39;ve get&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>