<?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>nRF52840 BLE DTM on custom board with Zephyr/NCS + LoRA radio</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/121356/nrf52840-ble-dtm-on-custom-board-with-zephyr-ncs-lora-radio</link><description>We have a design in EVT and we&amp;#39;re preparing for FCC testing. It&amp;#39;s a dual radio board with nRF52840 and a Semtech LR1110. Therefore, we need both to be active and transmitting during the test. 
 Is there a way to incorporate DTM code into an NCS 2.5.0</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 May 2025 07:31:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/121356/nrf52840-ble-dtm-on-custom-board-with-zephyr-ncs-lora-radio" /><item><title>RE: nRF52840 BLE DTM on custom board with Zephyr/NCS + LoRA radio</title><link>https://devzone.nordicsemi.com/thread/535023?ContentTypeID=1</link><pubDate>Tue, 13 May 2025 07:31:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2b217d86-3468-465b-801a-e44185710226</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Peter,&amp;nbsp;&lt;br /&gt;Have you looked at my suggestion about&amp;nbsp;calling&amp;nbsp;&lt;span&gt;clock_init() ? In my opinion it&amp;#39;s better to use the onoff clock library than using the registers directly.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 BLE DTM on custom board with Zephyr/NCS + LoRA radio</title><link>https://devzone.nordicsemi.com/thread/534944?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 15:07:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:38af6147-5449-4043-b39f-dee4548dcc98</guid><dc:creator>peter_littlebird</dc:creator><description>&lt;p&gt;Additional data and evidence:&lt;/p&gt;
&lt;p&gt;The HFXO is disabled as soon as VBUS is lost and this also affects operation of the NOR flash during OTA. So we need to address this somehow.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Loss of VBUS *does not affect* normal BLE stack operation. I can place the device in a shield box and I see it advertising at all the correct frequencies.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 BLE DTM on custom board with Zephyr/NCS + LoRA radio</title><link>https://devzone.nordicsemi.com/thread/534938?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 14:51:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:39f03315-71f5-4b22-9d73-d4076159d35b</guid><dc:creator>peter_littlebird</dc:creator><description>&lt;p&gt;Here is what we have to do to make it work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;  /**
   * The USB peripheral commandeers the HFXO and/or some other peripheral power domains and takes them down as soon as VBUS disappears. 
   * This makes concurrent USB and DTM operation impossible. The only way for DTM to work is to disable USB right now and re-start the HFXO right after.
   */
  usb_disable();
  k_msleep(100);

  // Start and validate HFXO
  NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
  NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;

  int timeout = 10000;
  while (!NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED &amp;amp;&amp;amp; --timeout)
  {
    k_busy_wait(1);
  }
  k_msleep(5);

  led_set(LED_YELLOW_MASK);
  led_set_brightness(LED_YELLOW_MASK, 40);

  radio_tx_start(channel, phy, payload, txpower_dbm);
&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The actual TX function looks like this:&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void radio_tx_start(uint8_t channel, uint8_t phy, enum ble_payload_type payload, int txpower_dbm)
{
  uint8_t frequency = ble_channel_to_frequency(channel);

  /* Disable RADIO before reconfiguring */
  NRF_RADIO-&amp;gt;TASKS_DISABLE = 1;
  while (NRF_RADIO-&amp;gt;STATE != RADIO_STATE_STATE_Disabled)
  {
  }

  /* Set frequency */
  NRF_RADIO-&amp;gt;FREQUENCY = frequency;

  /* Set TX power */
  switch (txpower_dbm)
  {
  case -40:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_Neg40dBm;
    break;
  case -20:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_Neg20dBm;
    break;
  case -4:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_Neg4dBm;
    break;
  case 0:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_0dBm;
    break;
  case 3:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_Pos3dBm;
    break;
  case 4:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_Pos4dBm;
    break;
  case 8:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_Pos8dBm;
    break;
  default:
    NRF_RADIO-&amp;gt;TXPOWER = RADIO_TXPOWER_TXPOWER_0dBm;
    break;
  }

  /* Set PHY */
  if (phy == 0x01)
  {
    NRF_RADIO-&amp;gt;MODE = RADIO_MODE_MODE_Ble_1Mbit;
  }
  else if (phy == 0x02)
  {
    NRF_RADIO-&amp;gt;MODE = RADIO_MODE_MODE_Ble_2Mbit;
  }
  else if (phy == 0x03)
  {
    NRF_RADIO-&amp;gt;MODE = RADIO_MODE_MODE_Ble_LR125Kbit;
  }
  else
  {
    NRF_RADIO-&amp;gt;MODE = RADIO_MODE_MODE_Ble_1Mbit;
  }

  if (payload == PAYLOAD_CARRIER)
  {
    /* Carrier only: no packet fields */
    NRF_RADIO-&amp;gt;PCNF0 = 0;
    NRF_RADIO-&amp;gt;PCNF1 = 0;
    NRF_RADIO-&amp;gt;BASE0 = 0;
    NRF_RADIO-&amp;gt;PREFIX0 = 0;
    NRF_RADIO-&amp;gt;PACKETPTR = 0;
    NRF_RADIO-&amp;gt;SHORTS = RADIO_SHORTS_READY_START_Msk;
  }
  else
  {
    /* Normal modulated packet */
    static uint8_t dummy_packet[40];
    generate_payload(dummy_packet, sizeof(dummy_packet), payload);
    NRF_RADIO-&amp;gt;PACKETPTR = (uint32_t)dummy_packet;

    NRF_RADIO-&amp;gt;PCNF0 = (8 &amp;lt;&amp;lt; RADIO_PCNF0_LFLEN_Pos);
    NRF_RADIO-&amp;gt;PCNF1 = (37 &amp;lt;&amp;lt; RADIO_PCNF1_MAXLEN_Pos) |
                       (3 &amp;lt;&amp;lt; RADIO_PCNF1_BALEN_Pos) |
                       (RADIO_PCNF1_ENDIAN_Little &amp;lt;&amp;lt; RADIO_PCNF1_ENDIAN_Pos);

    NRF_RADIO-&amp;gt;BASE0 = 0x89BED600;
    NRF_RADIO-&amp;gt;PREFIX0 = 0x8E;
    NRF_RADIO-&amp;gt;SHORTS = RADIO_SHORTS_READY_START_Msk | RADIO_SHORTS_END_START_Msk;
  }

  /* Start radio TX */
  NRF_RADIO-&amp;gt;TASKS_TXEN = 1;
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 BLE DTM on custom board with Zephyr/NCS + LoRA radio</title><link>https://devzone.nordicsemi.com/thread/534933?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 14:38:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ef6590bb-276d-46b6-9bac-de51a8ac1047</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Peter,&amp;nbsp;&lt;br /&gt;As far as I know the clock will be handled by our onoff manager and USB driver shouldn&amp;#39;t be able to turn off the HFCLK if the DTM is using it.&amp;nbsp;&lt;br /&gt;Could you check if&amp;nbsp;clock_init() is called in the dtm code ?&amp;nbsp;&lt;br /&gt;Make sure you have&amp;nbsp;CONFIG_CLOCK_CONTROL=y in the project config.&amp;nbsp;&lt;br /&gt;Please check if&amp;nbsp;onoff_request() is called and if it&amp;#39;s return 0. As far as I know if the module request clock, the onoff_release from the USB module won&amp;#39;t be able to turn it off.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;You can take a look at the usb_dc_nrfx.c to see how the clock release is called after the USB is detached (see&amp;nbsp;usbd_work_process_pwr_events() )&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 BLE DTM on custom board with Zephyr/NCS + LoRA radio</title><link>https://devzone.nordicsemi.com/thread/534915?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 13:29:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ced5201c-45df-4f8f-9303-9833a1eda83b</guid><dc:creator>peter_littlebird</dc:creator><description>&lt;p&gt;Over the weekend I was able to integrate DTM code into the project but we ran into a huge problem with USB. Since this is an NCS 2.5.0, it appears that the USB driver is not aware of the low level radio activity and takes away the 32MHz crystal as soon as it loses VBUS. This causes DTM to fail or the frequency to shift significantly. I had to devise a sequence where TX is started on LR1110 first, then DTM is configured on the nRF, then USB stops and DTM starts. This is the only way to test a device right now.&lt;/p&gt;
&lt;p&gt;Is there a way take control of the HF crystal away from the USB driver?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: nRF52840 BLE DTM on custom board with Zephyr/NCS + LoRA radio</title><link>https://devzone.nordicsemi.com/thread/534910?ContentTypeID=1</link><pubDate>Mon, 12 May 2025 13:22:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:368c20a4-e47b-4bcb-8166-abe684a794ff</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Peter,&amp;nbsp;&lt;br /&gt;&lt;br /&gt;We don&amp;#39;t have an example on how you can integrate DTM into your code. But the source code is available and you are free to modify it for your need. I assume you will need to have some code to convert the CLI command to be HCI command and send to the DTM code.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Another option which I think is easier is to use the&lt;a href="https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/peripheral/radio_test/README.html"&gt; radio_test sample&lt;/a&gt;, it&amp;#39;s designed with CLI interface instead of HCI. It should be easier to integrate into your code. The configuration is slightly different compare to DTM (for example the default addresses) but many of our customers use this for FCC.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>