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

Getting fake radio interrupts in receiver mode.

Hello!

I am using NRF51822 in receiver mode with enabled interrupt on ADDRESS event, and even if transmitter is switched off I still get a few messages every second. It also applies to END event. How should I solve this?

Main, radio configuration and irq handler fuctions are described below.

int main(void)
{
    clock_initialization();
	
	/* ... */
	
    // Set radio configuration parameters
    radio_configure();
    NRF_RADIO->PACKETPTR = (uint32_t)&packet;

	NRF_RADIO->INTENSET = RADIO_INTENSET_ADDRESS_Enabled << RADIO_INTENSET_ADDRESS_Pos;			
	NVIC_ClearPendingIRQ(RADIO_IRQn);
	NVIC_SetPriority(RADIO_IRQn, 0);
	NVIC_EnableIRQ(RADIO_IRQn);

	NRF_RADIO->EVENTS_READY = 0U;
	
    // Enable radio and wait for ready
	NRF_RADIO->TASKS_RXEN = 1U;
    while (NRF_RADIO->EVENTS_READY == 0U);
	
	NRF_RADIO->TASKS_START = 1U;

    while (true)
    {
    }
}
void radio_configure()
{
    // Radio config
    NRF_RADIO->TXPOWER   = (RADIO_TXPOWER_TXPOWER_Pos4dBm << RADIO_TXPOWER_TXPOWER_Pos);
    NRF_RADIO->FREQUENCY = 75UL;
    NRF_RADIO->MODE      = (RADIO_MODE_MODE_Nrf_2Mbit << RADIO_MODE_MODE_Pos);

    // Radio address config
    NRF_RADIO->PREFIX0 = 
        ((uint32_t)swap_bits(0xC3) << 24) // Prefix byte of address 3 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC2) << 16) // Prefix byte of address 2 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC1) << 8)  // Prefix byte of address 1 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC0) << 0); // Prefix byte of address 0 converted to nRF24L series format
  
    NRF_RADIO->PREFIX1 = 
        ((uint32_t)swap_bits(0xC7) << 24) // Prefix byte of address 7 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC6) << 16) // Prefix byte of address 6 converted to nRF24L series format
      | ((uint32_t)swap_bits(0xC4) << 0); // Prefix byte of address 4 converted to nRF24L series format

    NRF_RADIO->BASE0 = bytewise_bitswap(0x01234567UL);  // Base address for prefix 0 converted to nRF24L series format
    NRF_RADIO->BASE1 = bytewise_bitswap(0x89ABCDEFUL);  // Base address for prefix 1-7 converted to nRF24L series format
  
    NRF_RADIO->TXADDRESS   = 0x00UL;  // Set device address 0 to use when transmitting
    NRF_RADIO->RXADDRESSES = 0x01UL;  // Enable device address 0 to use to select which addresses to receive

    // Packet configuration
    NRF_RADIO->PCNF0 = (PACKET_S1_FIELD_SIZE     << RADIO_PCNF0_S1LEN_Pos) |
                       (PACKET_S0_FIELD_SIZE     << RADIO_PCNF0_S0LEN_Pos) |
                       (PACKET_LENGTH_FIELD_SIZE << RADIO_PCNF0_LFLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"

    // Packet configuration
    NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled << RADIO_PCNF1_WHITEEN_Pos) |
                       (RADIO_PCNF1_ENDIAN_Big       << RADIO_PCNF1_ENDIAN_Pos)  |
                       (PACKET_BASE_ADDRESS_LENGTH   << RADIO_PCNF1_BALEN_Pos)   |
                       (PACKET_STATIC_LENGTH         << RADIO_PCNF1_STATLEN_Pos) |
                       (PACKET_PAYLOAD_MAXSIZE       << RADIO_PCNF1_MAXLEN_Pos); //lint !e845 "The right argument to operator '|' is certain to be 0"

    // CRC Config
    NRF_RADIO->CRCCNF = (RADIO_CRCCNF_LEN_Disabled << RADIO_CRCCNF_LEN_Pos); // Number of checksum bits
    if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_Two << RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO->CRCINIT = 0xFFFFUL;   // Initial value      
        NRF_RADIO->CRCPOLY = 0x11021UL;  // CRC poly: x^16+x^12^x^5+1
    }
    else if ((NRF_RADIO->CRCCNF & RADIO_CRCCNF_LEN_Msk) == (RADIO_CRCCNF_LEN_One << RADIO_CRCCNF_LEN_Pos))
    {
        NRF_RADIO->CRCINIT = 0xFFUL;   // Initial value
        NRF_RADIO->CRCPOLY = 0x107UL;  // CRC poly: x^8+x^2^x^1+1
    }
}
 

void RADIO_IRQHandler(void)
{
	NRF_RADIO->EVENTS_ADDRESS = 0;
	
	/* ... */
	
	NRF_RADIO->TASKS_START = 1U;
}

defines from radio_configure.h:

#define PACKET_BASE_ADDRESS_LENGTH (1UL)
#define PACKET_STATIC_LENGTH (0UL)
#define PACKET_PAYLOAD_MAXSIZE (PACKET_STATIC_LENGTH)

Parents
  • Hi,

    It looks like to me that you have disabled CRC and use 1byte base address?

    When demodulating random noise on air, it statistically can hit any 2byte (prefix + base) address every 66ms, since 2byte is 65536 combinations @ 1Mbps.

    So I suggest to increase base length address and enable 2byte CRC to reduce risk of false address match and false received packet.

    Best regards,
    Kenneth

Reply
  • Hi,

    It looks like to me that you have disabled CRC and use 1byte base address?

    When demodulating random noise on air, it statistically can hit any 2byte (prefix + base) address every 66ms, since 2byte is 65536 combinations @ 1Mbps.

    So I suggest to increase base length address and enable 2byte CRC to reduce risk of false address match and false received packet.

    Best regards,
    Kenneth

Children
No Data
Related