Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

ESB Dynamic Address Change for Pairing

HI!

I'm using two nRF52840 boards to communicate using ESB.  The ESB API doesn't have a pairing protocol so I figured I'd write one without encryption or any bells and whistles.

Since ESB has 8 pipes, with pipe 0 having its own base address, I'm using that as a default pairing address.  Once the device is put into "pairing mode", a PTX device sends a payload on pipe 0 to the PRX device, also in pairing mode.  It's listening for messages on pipe 0.  Once it receives a message on this pipe, it sends back a payload with its own base 1 address.  So far, that has been working.

It gets odd when the PTX device wants to change its own address for pipes 1-7  (base address 1).  I store the new address into the same array used to initialize the ESB.  Then I call

nrf_esb_set_base_address_1(base_addr_1);
nrf_esb_set_prefixes(addr_prefix, 8);

base_addr_1 contains the new base 1 address gotten from the PRX device.

However, at some point on the PTX device, the base_addr_1 array gets changed back to the address that was used to set it up in esb_init.

Is there some other function I'm missing that I need to call to change to address?  I know that the address can change as because I ran a test with the example ESB code so that the address changes from two separate addresses on the device to the same address.  The results were that, at first the packets weren't received, but then after enough packets, the address changes and the packets are received.

Maybe it's something simple that I'm missing or something elsewhere in my code.  My question is, what could cause the base_addr_1 value to go back to its default value?

Thanks!

Parents
  • So what happens is the PTX device is going into low power state, and when it comes out of it, the new values put into the array are set to default.

    If I understand correctly, the example code stores a loop count value through sleep.  Would that be possible with an array?  How would that be done? The example code has the following:  

    void recover_state()
    {
        uint32_t            loop_count = 0;
        if ((NRF_POWER->GPREGRET >> 4) == RESET_MEMORY_TEST_BYTE)
        {
            // Take the loop_count value.
            base_addr_1          = (uint8_t)(NRF_POWER->GPREGRET & 0xFUL);
            NRF_POWER->GPREGRET = 0;
        }
    
        loop_count++;
        NRF_POWER->GPREGRET = ( (RESET_MEMORY_TEST_BYTE << 4) | loop_count);
    
        tx_payload.data[1] = loop_count << 4;
    }

Reply
  • So what happens is the PTX device is going into low power state, and when it comes out of it, the new values put into the array are set to default.

    If I understand correctly, the example code stores a loop count value through sleep.  Would that be possible with an array?  How would that be done? The example code has the following:  

    void recover_state()
    {
        uint32_t            loop_count = 0;
        if ((NRF_POWER->GPREGRET >> 4) == RESET_MEMORY_TEST_BYTE)
        {
            // Take the loop_count value.
            base_addr_1          = (uint8_t)(NRF_POWER->GPREGRET & 0xFUL);
            NRF_POWER->GPREGRET = 0;
        }
    
        loop_count++;
        NRF_POWER->GPREGRET = ( (RESET_MEMORY_TEST_BYTE << 4) | loop_count);
    
        tx_payload.data[1] = loop_count << 4;
    }

Children
No Data
Related