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

Odd behavior in tx radio and rx radio pairs

I am doing some custom work, and have discovered an odd bug, that I can not seem to figure out.

On the tx radio, I am transmitting a BLE ADV packet with the first 3 bytes 0x4225BB. On the receiving radio, I am receiving 0x422503. The receive radio's checksum is correct (per the crc register). The rest of the packet is correct.

I also tried to transmit a BLE ADV packet with first 3 bytes 0xAAAA0E. The receiving radio picked up 0xAA2A02 and again, the checksum is correct (per the crc register). The rest of the packet is correct, it only seems to effect the 2 bytes.

I have verified the memory of each the tx-er and rx-er at receive and transmit time, and it reinforces the above statements.

I am using a NRF52832 to transmit, and and NRF51822 to receive. I am using custom code, not the Nordic stack. I have tried this on multiple devices and the behavior is the same.

Is there something that I am missing?

Parents
  • void hal_radio_config(void) {

    NVIC_DisableIRQ(RADIO_IRQn);
    
    // cycle radio power
    NRF_RADIO->POWER = RADIO_POWER_POWER_Disabled << RADIO_POWER_POWER_Pos;
    NRF_RADIO->POWER = RADIO_POWER_POWER_Enabled << RADIO_POWER_POWER_Pos;
    
    NRF_RADIO->TXPOWER=0x00; //set lowest tx power
    NRF_RADIO->SHORTS = 0x000000000;
    
    //length on air of S0, S1, and LFLEN
    NRF_RADIO->PCNF0 =   (((1UL) << RADIO_PCNF0_S0LEN_Pos) & RADIO_PCNF0_S0LEN_Msk)
                       | (((2UL) << RADIO_PCNF0_S1LEN_Pos) & RADIO_PCNF0_S1LEN_Msk)
                       | (((6UL) << RADIO_PCNF0_LFLEN_Pos) & RADIO_PCNF0_LFLEN_Msk);
    
    //little endian, base address length (3 + 1 = 4), static length = 0, max length, enable payload	
    NRF_RADIO->PCNF1 =   (((RADIO_PCNF1_ENDIAN_Little)        << RADIO_PCNF1_ENDIAN_Pos) & RADIO_PCNF1_ENDIAN_Msk)
                       | (((3UL)                              << RADIO_PCNF1_BALEN_Pos)  & RADIO_PCNF1_BALEN_Msk)
                       | (((0UL)                              << RADIO_PCNF1_STATLEN_Pos)& RADIO_PCNF1_STATLEN_Msk)
                       | ((((uint32_t)DD_MAX_PAYLOAD_LENGTH)  << RADIO_PCNF1_MAXLEN_Pos) & RADIO_PCNF1_MAXLEN_Msk)
                       | ((RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos) & RADIO_PCNF1_WHITEEN_Msk);
    
    /* The CRC polynomial is fixed, and is set here. */
    /* The CRC initial value may change, and is set by */
    /* higher level modules as needed. */
    NRF_RADIO->CRCPOLY = (uint32_t)CRC_POLYNOMIAL_INIT_SETTINGS;
    NRF_RADIO->CRCCNF = (((RADIO_CRCCNF_SKIPADDR_Skip) << RADIO_CRCCNF_SKIPADDR_Pos) & RADIO_CRCCNF_SKIPADDR_Msk)
                      | (((RADIO_CRCCNF_LEN_Three)      << RADIO_CRCCNF_LEN_Pos)       & RADIO_CRCCNF_LEN_Msk);
    
    	//enable reception on logical address, what does this mean?
    NRF_RADIO->RXADDRESSES  = ( (RADIO_RXADDRESSES_ADDR0_Enabled) << RADIO_RXADDRESSES_ADDR0_Pos);
    
    	//set BLE mode
    NRF_RADIO->MODE    = ((RADIO_MODE_MODE_Ble_1Mbit) << RADIO_MODE_MODE_Pos) & RADIO_MODE_MODE_Msk;
    
    	//interframe space in us between end tx and begin tx
    NRF_RADIO->TIFS = 150;
    
    	//something with access address?
    NRF_RADIO->PREFIX0 = access_address[3];
    NRF_RADIO->BASE0   = ( (((uint32_t)access_address[2]) << 24) 
                         | (((uint32_t)access_address[1]) << 16)
                         | (((uint32_t)access_address[0]) << 8) );
    											 
    /* set dev match address */									 
    NRF_RADIO->DAB[0] = 0x4ae67dbe;  // 32 least significant
    NRF_RADIO->DAP[0] = 0x1172; //16 most significant
    NRF_RADIO->DACNF = (0x1) | (0x100); //enable addrress0
    
    //Initial value for CRC calculation.
    NRF_RADIO->CRCINIT = ((uint32_t)seed[0]) | ((uint32_t)seed[1])<<8 | ((uint32_t)seed[2])<<16;
    	
    NRF_RADIO->DATAWHITEIV=37;
    	
    NRF_RADIO->FREQUENCY = CHANNEL_IDX_TO_FREQ_OFFS(37); // ERIC
    	
    NVIC_EnableIRQ(RADIO_IRQn);
    	
    

    }

    Snippet that actually sends

    	NRF_RADIO->EVENTS_DISABLED = 0;
    NRF_RADIO->TASKS_DISABLE = 1;
    while(!NRF_RADIO->EVENTS_DISABLED);     //wait for radio to be disabled
    
    NRF_RADIO->EVENTS_READY=0;					 //clear flag
    NRF_RADIO->TASKS_TXEN=1;						 //enable radio in TX mode
    while(!NRF_RADIO->EVENTS_READY);     //wait for radio to be in tx mode
    
    NRF_RADIO->PACKETPTR = (uint32_t)&thisdata;
    
    NRF_RADIO->EVENTS_END = 0;					 //clear flag
    NRF_RADIO->TASKS_START = 1;  		     //its ready start task
    while(!NRF_RADIO->EVENTS_END); 	     //wait for radio to send
    
    //clear event
    NRF_RADIO->EVENTS_DISABLED = 0;
    NRF_RADIO->EVENTS_END = 0;
    NRF_RADIO->EVENTS_READY=0;
    
Reply
  • void hal_radio_config(void) {

    NVIC_DisableIRQ(RADIO_IRQn);
    
    // cycle radio power
    NRF_RADIO->POWER = RADIO_POWER_POWER_Disabled << RADIO_POWER_POWER_Pos;
    NRF_RADIO->POWER = RADIO_POWER_POWER_Enabled << RADIO_POWER_POWER_Pos;
    
    NRF_RADIO->TXPOWER=0x00; //set lowest tx power
    NRF_RADIO->SHORTS = 0x000000000;
    
    //length on air of S0, S1, and LFLEN
    NRF_RADIO->PCNF0 =   (((1UL) << RADIO_PCNF0_S0LEN_Pos) & RADIO_PCNF0_S0LEN_Msk)
                       | (((2UL) << RADIO_PCNF0_S1LEN_Pos) & RADIO_PCNF0_S1LEN_Msk)
                       | (((6UL) << RADIO_PCNF0_LFLEN_Pos) & RADIO_PCNF0_LFLEN_Msk);
    
    //little endian, base address length (3 + 1 = 4), static length = 0, max length, enable payload	
    NRF_RADIO->PCNF1 =   (((RADIO_PCNF1_ENDIAN_Little)        << RADIO_PCNF1_ENDIAN_Pos) & RADIO_PCNF1_ENDIAN_Msk)
                       | (((3UL)                              << RADIO_PCNF1_BALEN_Pos)  & RADIO_PCNF1_BALEN_Msk)
                       | (((0UL)                              << RADIO_PCNF1_STATLEN_Pos)& RADIO_PCNF1_STATLEN_Msk)
                       | ((((uint32_t)DD_MAX_PAYLOAD_LENGTH)  << RADIO_PCNF1_MAXLEN_Pos) & RADIO_PCNF1_MAXLEN_Msk)
                       | ((RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos) & RADIO_PCNF1_WHITEEN_Msk);
    
    /* The CRC polynomial is fixed, and is set here. */
    /* The CRC initial value may change, and is set by */
    /* higher level modules as needed. */
    NRF_RADIO->CRCPOLY = (uint32_t)CRC_POLYNOMIAL_INIT_SETTINGS;
    NRF_RADIO->CRCCNF = (((RADIO_CRCCNF_SKIPADDR_Skip) << RADIO_CRCCNF_SKIPADDR_Pos) & RADIO_CRCCNF_SKIPADDR_Msk)
                      | (((RADIO_CRCCNF_LEN_Three)      << RADIO_CRCCNF_LEN_Pos)       & RADIO_CRCCNF_LEN_Msk);
    
    	//enable reception on logical address, what does this mean?
    NRF_RADIO->RXADDRESSES  = ( (RADIO_RXADDRESSES_ADDR0_Enabled) << RADIO_RXADDRESSES_ADDR0_Pos);
    
    	//set BLE mode
    NRF_RADIO->MODE    = ((RADIO_MODE_MODE_Ble_1Mbit) << RADIO_MODE_MODE_Pos) & RADIO_MODE_MODE_Msk;
    
    	//interframe space in us between end tx and begin tx
    NRF_RADIO->TIFS = 150;
    
    	//something with access address?
    NRF_RADIO->PREFIX0 = access_address[3];
    NRF_RADIO->BASE0   = ( (((uint32_t)access_address[2]) << 24) 
                         | (((uint32_t)access_address[1]) << 16)
                         | (((uint32_t)access_address[0]) << 8) );
    											 
    /* set dev match address */									 
    NRF_RADIO->DAB[0] = 0x4ae67dbe;  // 32 least significant
    NRF_RADIO->DAP[0] = 0x1172; //16 most significant
    NRF_RADIO->DACNF = (0x1) | (0x100); //enable addrress0
    
    //Initial value for CRC calculation.
    NRF_RADIO->CRCINIT = ((uint32_t)seed[0]) | ((uint32_t)seed[1])<<8 | ((uint32_t)seed[2])<<16;
    	
    NRF_RADIO->DATAWHITEIV=37;
    	
    NRF_RADIO->FREQUENCY = CHANNEL_IDX_TO_FREQ_OFFS(37); // ERIC
    	
    NVIC_EnableIRQ(RADIO_IRQn);
    	
    

    }

    Snippet that actually sends

    	NRF_RADIO->EVENTS_DISABLED = 0;
    NRF_RADIO->TASKS_DISABLE = 1;
    while(!NRF_RADIO->EVENTS_DISABLED);     //wait for radio to be disabled
    
    NRF_RADIO->EVENTS_READY=0;					 //clear flag
    NRF_RADIO->TASKS_TXEN=1;						 //enable radio in TX mode
    while(!NRF_RADIO->EVENTS_READY);     //wait for radio to be in tx mode
    
    NRF_RADIO->PACKETPTR = (uint32_t)&thisdata;
    
    NRF_RADIO->EVENTS_END = 0;					 //clear flag
    NRF_RADIO->TASKS_START = 1;  		     //its ready start task
    while(!NRF_RADIO->EVENTS_END); 	     //wait for radio to send
    
    //clear event
    NRF_RADIO->EVENTS_DISABLED = 0;
    NRF_RADIO->EVENTS_END = 0;
    NRF_RADIO->EVENTS_READY=0;
    
Children
No Data
Related