<?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>How does the nRF52833 reply back to  nRF24L01+ with user data automatically?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/112772/how-does-the-nrf52833-reply-back-to-nrf24l01-with-user-data-automatically</link><description>Using the following code block nRF52833(PRX) can receive the data from PTX(nRF24L01+). 
 
 
 But how nRF52833 replies to nRF24L01+ with the ACK packet which includes user data?</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 05 Jul 2024 09:11:30 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/112772/how-does-the-nrf52833-reply-back-to-nrf24l01-with-user-data-automatically" /><item><title>RE: How does the nRF52833 reply back to  nRF24L01+ with user data automatically?</title><link>https://devzone.nordicsemi.com/thread/492401?ContentTypeID=1</link><pubDate>Fri, 05 Jul 2024 09:11:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:154ea779-7bcf-45d0-8f7b-7ac45cac0565</guid><dc:creator>JackLan</dc:creator><description>&lt;p&gt;Thanks.&lt;br /&gt;The following codeblock works.&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**
 * Copyright (c) 2014 - 2021, Nordic Semiconductor ASA
 *
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without modification,
 * are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice, this
 *    list of conditions and the following disclaimer.
 *
 * 2. Redistributions in binary form, except as embedded into a Nordic
 *    Semiconductor ASA integrated circuit in a product or a software update for
 *    such product, must reproduce the above copyright notice, this list of
 *    conditions and the following disclaimer in the documentation and/or other
 *    materials provided with the distribution.
 *
 * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
 *    contributors may be used to endorse or promote products derived from this
 *    software without specific prior written permission.
 *
 * 4. This software, with or without modification, must only be used with a
 *    Nordic Semiconductor ASA integrated circuit.
 *
 * 5. Any software provided in binary form under this license must not be reverse
 *    engineered, decompiled, modified and/or disassembled.
 *
 * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA &amp;quot;AS IS&amp;quot; AND ANY EXPRESS
 * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 */
#include &amp;quot;nrf_esb.h&amp;quot;

#include &amp;lt;stdbool.h&amp;gt;
#include &amp;lt;stdint.h&amp;gt;
#include &amp;quot;sdk_common.h&amp;quot;
#include &amp;quot;nrf.h&amp;quot;
#include &amp;quot;nrf_esb_error_codes.h&amp;quot;
#include &amp;quot;nrf_delay.h&amp;quot;
#include &amp;quot;nrf_gpio.h&amp;quot;
#include &amp;quot;nrf_error.h&amp;quot;
#include &amp;quot;boards.h&amp;quot;


#include &amp;quot;nrf_log.h&amp;quot;
#include &amp;quot;nrf_log_ctrl.h&amp;quot;
#include &amp;quot;nrf_log_default_backends.h&amp;quot;

uint8_t led_nr;

nrf_esb_payload_t rx_payload;
static nrf_esb_payload_t tx_payload = NRF_ESB_CREATE_PAYLOAD(0, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00);	

/*lint -save -esym(40, BUTTON_1) -esym(40, BUTTON_2) -esym(40, BUTTON_3) -esym(40, BUTTON_4) -esym(40, LED_1) -esym(40, LED_2) -esym(40, LED_3) -esym(40, LED_4) */
volatile static uint16_t recvCount = 0, countBak = 0, count;

void nrf_esb_event_handler(nrf_esb_evt_t const * p_event)
{
		//
    switch (p_event-&amp;gt;evt_id)
    {
        case NRF_ESB_EVENT_TX_SUCCESS:
            //NRF_LOG_DEBUG(&amp;quot;TX SUCCESS EVENT&amp;quot;);
            break;
        case NRF_ESB_EVENT_TX_FAILED:
            //NRF_LOG_DEBUG(&amp;quot;TX FAILED EVENT&amp;quot;);
            break;
        case NRF_ESB_EVENT_RX_RECEIVED:
            //NRF_LOG_DEBUG(&amp;quot;RX RECEIVED EVENT&amp;quot;);

            if (nrf_esb_read_rx_payload(&amp;amp;rx_payload) == NRF_SUCCESS)
            {
								recvCount = *((uint16_t*)rx_payload.data);
								count++;
								//if(countBak != recvCount)
								{
						      nrf_gpio_pin_write(LED_1, recvCount % 2);
									nrf_gpio_pin_write(LED_2, recvCount % 2);
									nrf_gpio_pin_write(LED_3, recvCount % 2);
									nrf_gpio_pin_write(LED_4, recvCount % 2);																			
									//NRF_LOG_DEBUG(&amp;quot;%d, %d&amp;quot;, recvCount, recvCount);									
								}
                // Set LEDs identical to the ones on the PTX.
/*
                nrf_gpio_pin_write(LED_1, !(rx_payload.data[1]%8&amp;gt;0 &amp;amp;&amp;amp; rx_payload.data[1]%8&amp;lt;=4));
                nrf_gpio_pin_write(LED_2, !(rx_payload.data[1]%8&amp;gt;1 &amp;amp;&amp;amp; rx_payload.data[1]%8&amp;lt;=5));
                nrf_gpio_pin_write(LED_3, !(rx_payload.data[1]%8&amp;gt;2 &amp;amp;&amp;amp; rx_payload.data[1]%8&amp;lt;=6));
                nrf_gpio_pin_write(LED_4, !(rx_payload.data[1]%8&amp;gt;3));
*/
								
								nrf_esb_write_payload(&amp;amp;tx_payload);

								//APP_ERROR_CHECK(err_code);
                //NRF_LOG_DEBUG(&amp;quot;Receiving packet: Length == %d, rssi == %d&amp;quot;, rx_payload.length, rx_payload.rssi);
            }
            break;
    }
}


void clocks_start( void )
{
    NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED = 0;
    NRF_CLOCK-&amp;gt;TASKS_HFCLKSTART = 1;

    while (NRF_CLOCK-&amp;gt;EVENTS_HFCLKSTARTED == 0);
}


void gpio_init( void )
{
    bsp_board_init(BSP_INIT_LEDS);
}


uint32_t esb_init( void )
{
    uint32_t err_code;
    /*
    uint8_t base_addr_0[4] = {0x43,0x10,0x10,0x01};
    uint8_t base_addr_1[4] = {0x43,0x10,0x10,0x01};
    uint8_t addr_prefix[8] = {0x34, 0x34, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 };
    */
    uint8_t base_addr_0[4] = {0xA0, 0xD3, 0xCA, 0x41};
    uint8_t base_addr_1[4] = {0xA0, 0xD3, 0xCA, 0x41};
    uint8_t addr_prefix[8] = {0x6A, 0x6A, 0xC3, 0xC4, 0xC5, 0xC6, 0xC7, 0xC8 };
    nrf_esb_config_t nrf_esb_config         = NRF_ESB_LEGACY_CONFIG;
    nrf_esb_config.payload_length           = 32;
    nrf_esb_config.protocol                 = NRF_ESB_PROTOCOL_ESB_DPL;
    nrf_esb_config.bitrate                  = NRF_ESB_BITRATE_2MBPS;
    nrf_esb_config.mode                     = NRF_ESB_MODE_PRX;
    nrf_esb_config.event_handler            = nrf_esb_event_handler;
    nrf_esb_config.selective_auto_ack       = true;

    err_code = nrf_esb_init(&amp;amp;nrf_esb_config);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_0(base_addr_0);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_base_address_1(base_addr_1);
    VERIFY_SUCCESS(err_code);

    err_code = nrf_esb_set_prefixes(addr_prefix, 8);
    VERIFY_SUCCESS(err_code);

    
    err_code = nrf_esb_set_rf_channel(12);
    VERIFY_SUCCESS(err_code);

    return err_code;
}


int main(void)
{
    uint32_t err_code;
    gpio_init();

    err_code = NRF_LOG_INIT(NULL);
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEFAULT_BACKENDS_INIT();

    clocks_start();

    err_code = esb_init();
    APP_ERROR_CHECK(err_code);

    NRF_LOG_DEBUG(&amp;quot;Enhanced ShockBurst Receiver Example started.&amp;quot;);

	tx_payload.noack = true;
	tx_payload.length = 2;
	tx_payload.pipe = 0;
	tx_payload.data[0] = 0x12;
	tx_payload.data[1] = 0x23;

	
    err_code = nrf_esb_start_rx();
    APP_ERROR_CHECK(err_code);

    while (true)
    {
				nrf_delay_ms(1000);
				NRF_LOG_DEBUG(&amp;quot;%d PS, %d&amp;quot;, count - countBak, recvCount);
				countBak = count;			
        //if (NRF_LOG_PROCESS() == false)
        {
        //    __WFE();
        }
    }
}
/*lint -restore */
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How does the nRF52833 reply back to  nRF24L01+ with user data automatically?</title><link>https://devzone.nordicsemi.com/thread/492396?ContentTypeID=1</link><pubDate>Fri, 05 Jul 2024 08:55:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:32cae3ae-6cb3-4788-b559-098cf5c2f314</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;See this guide here:&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/esb_users_guide.html?cp=9_1_5_3"&gt;https://infocenter.nordicsemi.com/topic/sdk_nrf5_v17.1.0/esb_users_guide.html?cp=9_1_5_3&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1720169713489v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How does the nRF52833 reply back to  nRF24L01+ with user data automatically?</title><link>https://devzone.nordicsemi.com/thread/492395?ContentTypeID=1</link><pubDate>Fri, 05 Jul 2024 08:54:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d8d869e2-e5a3-4140-8052-a71042c462fc</guid><dc:creator>JackLan</dc:creator><description>&lt;p&gt;Take the following case as example:&lt;/p&gt;
&lt;p&gt;Once the nRF52833(PRX) &lt;span&gt;received&amp;nbsp;&lt;/span&gt;the data from&amp;nbsp;&lt;span&gt;nRF24L01+&amp;nbsp;(PTX).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;The nRF52833(PRX) send back the [0x01, 0x02, 0x03,&amp;nbsp;0x04, 0x05, 0x06] data to&amp;nbsp;nRF24L01+&amp;nbsp;(PTX).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>