<?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>Advertising using raw radio registers with nRF52832 (without SoftDevice)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/107076/advertising-using-raw-radio-registers-with-nrf52832-without-softdevice</link><description>Hi, 
 I&amp;#39;m trying to write a small sample code that performs BLE advertising without using SoftDevice but instead using the raw radio registers. 
 I&amp;#39;ve looked at the solar_sensor_beacon sample on the Nordic GitHub repo and my code looks very similar. </description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 09 Jan 2024 07:52:56 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/107076/advertising-using-raw-radio-registers-with-nrf52832-without-softdevice" /><item><title>RE: Advertising using raw radio registers with nRF52832 (without SoftDevice)</title><link>https://devzone.nordicsemi.com/thread/463277?ContentTypeID=1</link><pubDate>Tue, 09 Jan 2024 07:52:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:056224a9-efd0-4483-9872-e3fe62fc5333</guid><dc:creator>Samuele Forconi</dc:creator><description>&lt;p&gt;Yes, you can choose to&amp;nbsp;set PCNF0 in this way:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* PCNF-&amp;gt; Packet Configuration. Now we need to configure the sizes S0, S1 and length field to match the datapacket format of the advertisement packets. */
NRF_RADIO-&amp;gt;PCNF0 =  (
		              (((1UL) &amp;lt;&amp;lt; RADIO_PCNF0_S0LEN_Pos) &amp;amp; RADIO_PCNF0_S0LEN_Msk)    // length of S0 field in bytes 0-1.
		            | (((2UL) &amp;lt;&amp;lt; RADIO_PCNF0_S1LEN_Pos) &amp;amp; RADIO_PCNF0_S1LEN_Msk)    // length of S1 field in bits 0-8.
		            | (((6UL) &amp;lt;&amp;lt; RADIO_PCNF0_LFLEN_Pos) &amp;amp; RADIO_PCNF0_LFLEN_Msk)    // length of length field in bits 0-8.
		          );

// Mapped in 3 bytes into RAM
m_adv_pdu[0]  = 0x40 | 0x02;
m_adv_pdu[1]  = 0;
m_adv_pdu[2]  = 0;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;or&amp;nbsp;in&amp;nbsp;this other way:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/* PCNF-&amp;gt; Packet Configuration. Now we need to configure the sizes S0, S1 and length field to match the datapacket format of the advertisement packets. */
NRF_RADIO-&amp;gt;PCNF0 =  (
		              (((1UL) &amp;lt;&amp;lt; RADIO_PCNF0_S0LEN_Pos) &amp;amp; RADIO_PCNF0_S0LEN_Msk)    // length of S0 field in bytes 0-1.
		            | (((0UL) &amp;lt;&amp;lt; RADIO_PCNF0_S1LEN_Pos) &amp;amp; RADIO_PCNF0_S1LEN_Msk)    // length of S1 field in bits 0-8.
		            | (((8UL) &amp;lt;&amp;lt; RADIO_PCNF0_LFLEN_Pos) &amp;amp; RADIO_PCNF0_LFLEN_Msk)    // length of length field in bits 0-8.
		          );
		          
m_adv_pdu[0]  = 0x40 | 0x02;
m_adv_pdu[1]  = 0;&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising using raw radio registers with nRF52832 (without SoftDevice)</title><link>https://devzone.nordicsemi.com/thread/463230?ContentTypeID=1</link><pubDate>Mon, 08 Jan 2024 19:28:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89b5a87f-37f8-4f38-b75c-9916ef8ed3da</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;Good news. Looking at the advertising packet shows that the Radio is slightly confusing as the memory layout is different from the on-air layout due to the way the optional S0, Length and S1 fields are handled. These are my notes trying to clarify; I added an optional 0xFF manufacturing data field.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;// BLE Advertising Packet
// ======================
// Every packet begins with an 8 bit preamble, an alternating binary sequence. This is followed by a 32 bit access
// address (AA) which can be thought of as a unique identifier which defines a particular connection. When a
// device (master or slave) transmits on an advertising channel it uses a fixed value of 0x8e89bed6 as the access
// address.
// Following the 32 bit access address are optional S0, LENGTH and S1 fields then a variable length Protocol Data
// Unit (PDU) which contains the message data payload. Finally all packets end with a 24 bit CRC.
// By default, the Nordic BLE address is derived from the NRF_FICR-&amp;gt;DEVICEADDR[] and is 48 bits in length (6 bytes)
// If S0, LENGTH or S1 are specified with zero length their fields will be omitted in memory, otherwise each
// field will be represented as a separate byte, regardless of the number of bits in their on-air counterpart
// For the field sizes defined in bits, the occupation in RAM will always be rounded up to the next full byte size
// (for instance 3 bit length will allocate 1 byte in RAM, 9 bit length will allocate 2 bytes, etc.).
// On-air packet layout (Note Header in RAM is 3 bytes if S0INC is &amp;#39;1&amp;#39;)
// +-------------------------------------------------------------------------------------------------------------------------+
// |                                         BLE Advertising Packet - Legacy                                                 |
// +-------------------------------------------------------------------------------------------------------------------------+
// |                                         1MHz: 47 octets max total length                                                |
// +--------+-------+------------------------------------------------------------------------------------------+------+------+
// |        |Access |                                                                                          | Add  |      |
// |Preamble|Address|                   Protocol Data Unit PDU                                                 | On   | CRCC | Tone Ext
// +--------+-------+------------------------------------------------------------------------------------------+------+------+
// |   1(2) |   4   |                                    2 - 39                                                | (0)  |  3   | 16 - 160uSec
// |        |       +-----------------+------------------------------------------------------------------------+      |      |
// |        |       |    Header       |                  Payload                                               |      |      |
// |        |       +-----------------+------------------------------------------------------------------------+      |      |
// |        |       |       2         |                  0 - 37                                                |      |      |
// |        |       +-----+-----+-----+------------------------------------------------------------------------+      |      |
// |        |       | Opt | Opt | Opt |  MAC Addr  |     AdvData List (example 3 fields)                       |      |      |
// |        |       | S0  | Len | S1  +------------+-----------------------------------------------------------+      |      |
// |        |       |-----+-----+-----|    6       |     0 - 31                                                |      |      |
// |        |       | (1) | (1) | (1) |            +-------------------+-------------------+-------------------+      |      |
// |        |       |     |     |     |            |    AdvData Flags  |    AdvData Name   |   (AdvData Data)  |      |      |
// |        |       |     |     |     |            +-------------------+-------------------+-------------------+      |      |
// |        |       |     |     |     |            |        3          |          6        |       0 - 22      |      |      |
// |        |       |     |     |     |            +-----+------+------+-----+------+------+-----+------+------+      |      |
// |        |       |     |     |     |            | Len | Type | Data | Len | Type | Data | Len | Type | Data |      |      |
// |        |       |     |     |     |            +-----+------+------+-----+------+------+-----+------+------+      |      |
// |        |       |     |     |     |            |  1  |  1   |  1   |  1  |  1   |  4   |  1  |  1   |  20  |      |      |
// |        |       |     |     |     |            |     |      |      |     |      |      |     |      |      |      |      |
// |  1(2)  |  4    | (1) | (1) | (1) |   6        |  1  |  1   |  1   |  1  |  1   |  4   |  1  |  1   |  20  | (0)  |  3   |
// +--------+-------+-----+-----+-----+------------+-----+------+------+-----+------+------+-----+------+------+------+------+

    m_adv_pdu[0]  = 0x40 | 0x02;    // S0:     Optional First header byte: TxAdd|RxAdd (0x40) + PDU Type
    m_adv_pdu[1]  = 0;              // Length: Optional Second header byte: LENGTH (will be updated at the end)
    m_adv_pdu[2]  = 0;              // S1:     Optional Third header byte&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Edit: To clarify, the Header has just 2 buyts transmitted over-the-air, but the Radio hardware uses 3 bytes in RAM for this 2-byte Header. I also updated the table above.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising using raw radio registers with nRF52832 (without SoftDevice)</title><link>https://devzone.nordicsemi.com/thread/462700?ContentTypeID=1</link><pubDate>Thu, 04 Jan 2024 13:41:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b11a78c6-84fc-4ad9-b28c-ddb0acb8f415</guid><dc:creator>Samuele Forconi</dc:creator><description>&lt;p&gt;Great! That was exactly what was wrong!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertising using raw radio registers with nRF52832 (without SoftDevice)</title><link>https://devzone.nordicsemi.com/thread/462592?ContentTypeID=1</link><pubDate>Wed, 03 Jan 2024 20:12:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:35726fe5-2647-45b1-b116-ce3921e129fe</guid><dc:creator>hmolesworth</dc:creator><description>&lt;p&gt;The vector is incorrect, the Radio uses a fixed vector not a register pointer to a vector; it&amp;#39;s a simple fix:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;Change
void nrf_radio_event(void)
{

to
void RADIO_IRQHandler(void)
{&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I also moved the order of starting the transmission, that might not matter:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;Complete setup before very last thing starting transmission:

    /* trigger task early, the rest of the setup can be done in RXRU */
    NRF_RADIO-&amp;gt;TASKS_TXEN = 1;
    NRF_LOG_INFO(&amp;quot;TXEN&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>