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

Direct use of 2.4 GHz radio

I have done a number of BLE projects using this chip. I am exploring two potential applications which would use the 2.4 GHz radio, transmit only, in a non-standard way. I can't seem to get it to come on, probably missing some very simple step. I have built an application using the BLE to UART example, but cut off the code before it enables the softdevice. My test code looks like this, called in an infinite loop:

void SendPacket (void)
{
static unsigned char Buf [255];
int i;
for (i = 0; i < sizeof Buf; ++i) Buf [i] = 0x55;
for (i = 1000; i; --i)
   {
   printf ("%c", '0' + NRF_RADIO -> STATE);
   if (NRF_RADIO -> EVENTS_READY)
      break;
   }
//NRF_RADIO -> TASKS_DISABLE = 1;
NRF_RADIO -> PACKETPTR = (unsigned long) Buf;
NRF_RADIO -> FREQUENCY = 80;
NRF_RADIO -> TXPOWER = 4;
NRF_RADIO -> MODE = 4;
NRF_RADIO -> PCNF0 = 0;
NRF_RADIO -> PCNF1 = 0x0002FFFF;
NRF_RADIO -> SHORTS = 0x00000007;
NRF_RADIO -> TASKS_TXEN = 1;
//for (i = 100; i; --i);
//NRF_RADIO -> TASKS_START = 1;
}

Parents
  • Hi Steve,

    you didn't say what's wrong exactly - the code hangs, the radio doesn't go to READY state, you see no packets (there's some device tuned to receive them, right?), or something else?

    Did you configure TX address in PREFIX0 and PREFIX1, are they the same at receiver and transmitter? I would suggest to explicitly configure all radio registers, starting from NRF_RADIO->POWER=1. Also, for 2-Mbit mode, preamble length should be 2 bytes.

    My test code looks like this, called in an infinite loop

    As you enable shortcuts to restart transmission, an infinite loop is unnecessary.

  • I am monitoring the output with a spectrum analyzer, and I never see a carrier. I did not set the addresses because I am less interested in the content than in the carrier and its modulation. Good point about the shortcuts, but I was not aware it would actually restart transmission. So, how do I get it to start transmission in the first place?

  • Try to start with NRF_RADIO->POWER=1, and set address registers to something different from zero (it's known that zero access address doesn't work in rx mode, not sure for tx).

    I have built an application using the BLE to UART example, but cut off the code before it enables the softdevice.

    does this mean that softdevice is NOT enabled? could you post full code here?

Reply Children
  • My code currently looks like this:

    void SendPacket (void)
    {
    static unsigned char Buf [255];
    int i;
    static int Freq;
    for (i = 30000; i; --i)
       {
       if (NRF_RADIO -> EVENTS_READY)
          {
          LEDS_INVERT(1 << leds_list[1]);
          break;
          }
       }
    NRF_RADIO -> TASKS_STOP = 1;
    NRF_RADIO -> TASKS_DISABLE = 1;
    NRF_RADIO -> POWER = 0;
    if (Buf [0] != 0x55)
       for (i = 0; i < sizeof Buf; ++i)
          Buf [i] = 0x55;
    NRF_RADIO -> POWER = 1;

    for (i = 30; i; --i)
       {
       if (NRF_RADIO -> EVENTS_READY)
          {
          LEDS_INVERT(1 << leds_list[2]);
          break;
          }
       }

    NRF_RADIO -> TASKS_DISABLE = 1;
    NRF_RADIO -> PACKETPTR = (unsigned long) Buf;
    NRF_RADIO -> FREQUENCY = 20; //Freq++;
    if (Freq >= 80) Freq = 80;
    NRF_RADIO -> TXPOWER = 4;
    NRF_RADIO -> TXADDRESS = 1;
    for (i = 0; i < 8; ++i)
       {
       NRF_RADIO -> DAB [i] = 0x55555555;
       NRF_RADIO -> DAP [i] = 0x5555;
       }
    NRF_RADIO -> RXADDRESSES = 0;
    NRF_RADIO -> CRCCNF = 0;
    NRF_RADIO -> MODECNF0 = 0x00000201;
    NRF_RADIO -> MODE = 0;
    NRF_RADIO -> PCNF0 = 0x00000107;
    NRF_RADIO -> PCNF1 = 0x0002FFFF;
    NRF_RADIO -> TIFS = 1;
    NRF_RADIO -> DACNF = 0x0000FF00;
    NRF_RADIO -> PREFIX0 = 0x55555555;
    NRF_RADIO -> PREFIX1 = 0x55555555;
    NRF_RADIO -> SHORTS = 0x00000023;
    NRF_RADIO -> TASKS_TXEN = 1;
    for (i = 30000; i; --i)
       if (NRF_RADIO -> EVENTS_READY)
          {
          LEDS_INVERT(1 << leds_list[3]);
          break;
          }
    //for (i = 30000; i; --i)
       NRF_RADIO -> TASKS_START = 1;
    LEDS_INVERT(1 << leds_list[0]);
    }

    I have tried running it after having run another application that uses the softdevice, and also after a clean start from a power cycle. I have once or twice seen what appears to be a carrier on my spectrum analyzer, but I've never been able to reliably duplicate it. Does this radio section actually work per the datasheet?

Related