This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

GPIO setup parameters for AoA Antenna switching

I have an issue with getting the I/Os correctly setup for antenna switching.

I am running the radio_test example code with the following modifications. 

So far, I have the following code for the GPIO setup:

//Defines are at top of file
#define ANT1 NRF_GPIO_PIN_MAP(0,17)
#define ANT2 NRF_GPIO_PIN_MAP(1,8)
#define ANT3 NRF_GPIO_PIN_MAP(1,7)
#define ANT4 NRF_GPIO_PIN_MAP(1,6)

//other support code

//Pin config
nrf_gpio_pin_clear(ANT1);
nrf_gpio_cfg_output(ANT1);
nrf_gpio_pin_clear(ANT2);
nrf_gpio_cfg_output(ANT2);
nrf_gpio_pin_clear(ANT3);
nrf_gpio_cfg_output(ANT3);
nrf_gpio_pin_clear(ANT4);
nrf_gpio_cfg_output(ANT4);

//DFE pin config
NRF_RADIO->PSEL.DFEGPIO[0] = ANT1; //(P0.17)
NRF_RADIO->PSEL.DFEGPIO[1] = ANT2; //(P1.08)
NRF_RADIO->PSEL.DFEGPIO[2] = ANT3; //(P1.07)
NRF_RADIO->PSEL.DFEGPIO[4] = ANT4; //(P1.06)

NRF_RADIO->SWITCHPATTERN = 1; //Only P0.07 active
NRF_RADIO->SWITCHPATTERN = 2; //Only P1.08 active
NRF_RADIO->SWITCHPATTERN = 4; //Only P1.07 active
NRF_RADIO->SWITCHPATTERN = 8; //Only P1.06 active

NRF_RADIO->DFEMODE = RADIO_DFEMODE_DFEOPMODE_AoA;
NRF_RADIO->DFECTRL1 = 10 << RADIO_DFECTRL1_NUMBEROF8US_Pos | 
                       1 << RADIO_DFECTRL1_DFEINEXTENSION_Pos;

Then in the radio_test.c file, I include in the function radio_rx( ...)

uint32_t g_iq_packet[RADIO_MAX_PAYLOAD_LEN];

void radio_rx(....)
{
//orig example code still exists here, only not shown
    NRF_RADIO->DFEPACKET.PTR = (uint32_t)g_iq_packet;

}

From a board running the radio_test example, I issue the 'start_tx_modulated_carrier' command the immediately issue the 'start_rx" command on a seperate DK also running the radio_test example with the above modifications.

I expected to see a short duration square wave on each of the antenna GPIO pins, so, 4 square waves cascading in time. However from my logic analyzer capture, you can clearly see that is not the case.

How should I be setting up the config registers to fire each of the pins.  Nothing else is connected to the board except the logic analyzer.

Also, how do I correlate the IQ data from the DFEPACKET.PTR to the specific antenna?

Parents
  • A result of some tests:

    I have my configuration as follows:

    NRF_RADIO->DFEMODE = RADIO_DFEMODE_DFEOPMODE_AoA;
    NRF_RADIO->DFECTRL1 = 3 << RADIO_DFECTRL1_NUMBEROF8US_Pos | 
                           1 << RADIO_DFECTRL1_DFEINEXTENSION_Pos |
                           3 << RADIO_DFECTRL1_TSWITCHSPACING_Pos |
                           1 << RADIO_DFECTRL1_TSAMPLESPACINGREF_Pos |
                           3 << RADIO_DFECTRL1_TSAMPLESPACING_Pos ;
    
    
    NRF_RADIO->CTEINLINECONF = 1 << RADIO_CTEINLINECONF_CTEERRORHANDLING_Pos |
                               0 << RADIO_CTEINLINECONF_CTEINFOINS1_Pos;

    Which gives me a response on the RX side as the following:

    Received payload:
    Buffered IQ Samples:14
    Data0: -130, 26624, 
    Data1:  -157, 9216, 
    Data2:  -96, 30208, 
    Data3:  -13, -768, 
    Data4:  1, -2816, 
    Data5:  -117, 29440, 
    Data6:  -11, 17664, 
    Data7: 1, -5376, 
    Data8:  5, -2560, 
    Data9:  -11, 17152,
    Data10: 70, 22016,
    Data11: 12, -4864,
    Data12:  5, -1536, 
    Data13:  54, 19456

    The first number is the I and the second is the Q.  With how I have the RX side configured, my NUMBEROF8US is 3, meaning I have 24uS total. The TSAMPLESPACINGRED is set to 4uS ann my TSAMPLESPACING and TSWITCHSPACING is set to 1uS intervals.

    I dont understand how I am getting 14 IQ samples. If I am getting 2 samples in my REFERENCE period, that would leave 12 samples for IQ. but then that would mean my my total time is  4uS (guard band) + 8uS (reference) + 12uS(Sample time) + 12uS ( Switching time) = 36uS.  

    Can you help shed light?

    Thanks!

  • Are you setting NRF_RADIO->DFEPACKET.MAXCNT  and then checking NRF_RADIO->DFEPACKET.AMOUNT before grabbing the samples?

  • Hi Pete,

    Yes, I specify NRF_RADIO->DFEPACKET.MAXCNT = 64; 

    The data in the read buffer is driven by the the above config, specifically the DFECTRL1 register. In this case, how I am getting the "Buffered IQ Samples:14", is by reading the NRF_RADIO->DFEPACKET.AMOUNT.

  • If you see at your Q values in hex, you'll note that low byte is always 0x00. Either you're reading it as MSB instead of LSB, or byte offset is wrong. Also, did you set SAMPLETYPE to IQ?

  • Hi Dmitry,

    How I am parsing the IQ data is as follows:

    i_data = (int16_t)(g_iq_packet[i] & 0x0000FFFF);
    q_data = (int16_t)((g_iq_packet[i] & 0xFFFF0000)>>8);

    I do not EXPLICITLY set to read IQ data, but I have validated that the SAMPLETYPE bit has remained 0 in the DDFECTRL1 register.

  • Now it's clear )  should be

    q_data = (int16_t)((g_iq_packet[i] & 0xFFFF0000)>>16);

Reply Children
  • Well, that certainly looks a bit better...

    The data after shifting the data the correct 16 bits vs the orig 8 bits.

    Buffered IQ Samples:14
    Data0: -122, -107
    Data1: -63, -148
    Data2:  125, -102
    Data3: 58, -22
    Data4: 17, 32
    Data5:  44, 60
    Data6: 171, 0
    Data7:  57, 27
    Data8: -4, 36
    Data9:  7, 74
    Data10: 157, 56
    Data11: 42, 48
    Data12: -18, 27
    Data13: -27, 70

    I have a 4 multiplexor antenna connected to this,  does that mean data0 and data1 are from the reference period? then data2, 6 and 10 would be from the same antenna?

  • First of all, I'm not sure that your samples are in sync with switching, and I don't know how to set up DFECTRL2 in right way (maybe somebody could explain this moment?). That's why I suggested to configure maximum oversampling and watch on I/Q waves to find where switching really occured.

    does that mean data0 and data1 are from the reference period

    yes, if DFECTRL2 vaules are set up properly, you will get first two samples from reference period. But two samples is definitely not enough to measure frequency offset, it's better to average it at least from 8 samples.

    then data2, 6 and 10 would be from the same antenna?

    seems you're right - again, with right settings in DFECTRL2.

  • That's more like it. Well spotted Dmitry. Before using multiple antennas you might want to dump your samples into a spreadsheet to confirm that you're getting good data. Here's mine with 0.125us sampling from a 1Mbps CTE :

    (The MagPhase plot is not aligned with IQ plot because the data comes from 2 different runs). I believe the discontinuity at 8us (the end of the reference period) is expected. 

  • Thank you for your suggestion Dmitry, that helped make the data sane.

    From my 4-antenna switching, I am seeing the following:

    if I calculate 1000 * atan(q / i) I get :

    Which is starting to look better, but I am just trying to understand what happens during switching. Any insight on that? ( the 1000 multiplier was merely to get the nrf_cli_fprintf to accept the number as it is natively in floating point and I am doing a dirty conversion to fixed point)

    My settings for this test:

    NRF_RADIO->DFECTRL1 = 3 << RADIO_DFECTRL1_NUMBEROF8US_Pos |
    1 << RADIO_DFECTRL1_DFEINEXTENSION_Pos |
    3 << RADIO_DFECTRL1_TSWITCHSPACING_Pos |
    6 << RADIO_DFECTRL1_TSAMPLESPACINGREF_Pos |
    6 << RADIO_DFECTRL1_TSAMPLESPACING_Pos ;

  • A second half looks like switching results. The distance between points from the same antenna is 16 samples (2us).

    It seems your antenna switch is not very fast. You can look at results from my board with SKY66112:

Related