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

register setting problem on NRF52833!

based on nRF SDK 16 radio (peripheral)  example, in radio_config file, i set registers of TXPOWER, FREQUENCY, MODE, PCNF0, PCNF1 (and ADDR and CRC related registers) and also some DFE related registers including: DFEMODE,  CTEINLINECONF, DFECTRL1, DFEPACKET.

in the application i print the actual register values before executing radio_config() function and also after that; to check what are actual register values before and after configuration. the result i get shows that only MODE, PCNF0 and PCNF1  (and also ADDR and CRC related register) are correctly set, and other registers like TXPOWER, FREQUENCY and all of DFE related registers (DFEMODE,  CTEINLINECONF, DFECTRL1, DFEPACKET)  are left unchanged!

note that i have configured the AOA mode for RX.

where i  went wrong?

Parents
  • Are you using a SoftDevice?

    Note that the SoftDevice locks access to certain registers, so you cannot access them directly - you have to go via the appropriate API ...

  • void radio_configure()
    {
        // Radio config
        NRF_RADIO->TXPOWER   = (RADIO_TXPOWER_TXPOWER_Pos4dBm << RADIO_TXPOWER_TXPOWER_Pos);
        NRF_RADIO->FREQUENCY = 7UL;  // Frequency bin 2, 2402MHz
        NRF_RADIO->MODE      = (RADIO_MODE_MODE_Ble_1Mbit << 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_Two << 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
        }
    
    
            // ------------- DFE Config (Direction Finding Mode) --------------- //
        //@ tarnsmitter
        NRF_RADIO->DFEMODE = (RADIO_DFEMODE_DFEOPMODE_AoA << RADIO_DFEMODE_DFEOPMODE_Pos); // set DFEMODE as AOA
        
        /**
         * @brief configuring the radio in DFE mode with this settings:
         * CTEINLINECTRLEN = 1 >>>> inline configuration enabled
         * CTEINFOINS1 = NotInS1 >>>> CTEinfo settings for ADV PDU case 
        */
    
        NRF_RADIO->CTEINLINECONF = (RADIO_CTEINLINECONF_CTEINLINECTRLEN_Enabled  << RADIO_CTEINLINECONF_CTEINLINECTRLEN_Pos)|
                                   (RADIO_CTEINLINECONF_CTEINFOINS1_NotInS1      << RADIO_CTEINLINECONF_CTEINFOINS1_Pos)|
                                   (RADIO_CTEINLINECONF_CTEINLINERXMODE2US_125ns << RADIO_CTEINLINECONF_CTEINLINERXMODE2US_Pos); // set sample spacing equal to 125ns
    
    
        NRF_RADIO->DFECTRL1 = ((uint32_t)CTE_LENGTH_IN_8US             <<  RADIO_DFECTRL1_NUMBEROF8US_Pos)| // set CTE time length for TX
                              (RADIO_DFECTRL1_TSWITCHSPACING_4us       <<  RADIO_DFECTRL1_TSWITCHSPACING_Pos)|
                              (RADIO_DFECTRL1_TSAMPLESPACINGREF_125ns  <<  RADIO_DFECTRL1_TSAMPLESPACINGREF_Pos); //set switch time between atennas equal to 4us 
         
    
        NRF_RADIO->DFEPACKET.MAXCNT = (IQ_SAMP_BUFFER_SIZE << RADIO_DFEPACKET_MAXCNT_MAXCNT_Pos);
    
    }

Reply
  • void radio_configure()
    {
        // Radio config
        NRF_RADIO->TXPOWER   = (RADIO_TXPOWER_TXPOWER_Pos4dBm << RADIO_TXPOWER_TXPOWER_Pos);
        NRF_RADIO->FREQUENCY = 7UL;  // Frequency bin 2, 2402MHz
        NRF_RADIO->MODE      = (RADIO_MODE_MODE_Ble_1Mbit << 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_Two << 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
        }
    
    
            // ------------- DFE Config (Direction Finding Mode) --------------- //
        //@ tarnsmitter
        NRF_RADIO->DFEMODE = (RADIO_DFEMODE_DFEOPMODE_AoA << RADIO_DFEMODE_DFEOPMODE_Pos); // set DFEMODE as AOA
        
        /**
         * @brief configuring the radio in DFE mode with this settings:
         * CTEINLINECTRLEN = 1 >>>> inline configuration enabled
         * CTEINFOINS1 = NotInS1 >>>> CTEinfo settings for ADV PDU case 
        */
    
        NRF_RADIO->CTEINLINECONF = (RADIO_CTEINLINECONF_CTEINLINECTRLEN_Enabled  << RADIO_CTEINLINECONF_CTEINLINECTRLEN_Pos)|
                                   (RADIO_CTEINLINECONF_CTEINFOINS1_NotInS1      << RADIO_CTEINLINECONF_CTEINFOINS1_Pos)|
                                   (RADIO_CTEINLINECONF_CTEINLINERXMODE2US_125ns << RADIO_CTEINLINECONF_CTEINLINERXMODE2US_Pos); // set sample spacing equal to 125ns
    
    
        NRF_RADIO->DFECTRL1 = ((uint32_t)CTE_LENGTH_IN_8US             <<  RADIO_DFECTRL1_NUMBEROF8US_Pos)| // set CTE time length for TX
                              (RADIO_DFECTRL1_TSWITCHSPACING_4us       <<  RADIO_DFECTRL1_TSWITCHSPACING_Pos)|
                              (RADIO_DFECTRL1_TSAMPLESPACINGREF_125ns  <<  RADIO_DFECTRL1_TSAMPLESPACINGREF_Pos); //set switch time between atennas equal to 4us 
         
    
        NRF_RADIO->DFEPACKET.MAXCNT = (IQ_SAMP_BUFFER_SIZE << RADIO_DFEPACKET_MAXCNT_MAXCNT_Pos);
    
    }

Children
Related