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

Adapt the timesync demo to work with BLE LR (Coded Phy)

Hello,

i'm are trying to modify the timesync demo (https://devzone.nordicsemi.com/nordic/short-range-guides/b/bluetooth-low-energy/posts/wireless-timer-synchronization-among-nrf5-devices) to work with BLE LR 500 or 125kbits.

I work with the BL653 develoment board from Laird which uses the NRF52833 and the SDK 16.0.0 with S140 SoftDevice.

The NRF 2Mbit mode is working correctly, but i have problems with modifying the code to work with the LR 125kBit mode.

I tried to modify the radio parameters in the update_radio_parameters function as seen below. But I'm not sure if the modifications are correct.

static void update_radio_parameters(sync_pkt_t * p_pkt)
{
    // TX power
    NRF_RADIO->TXPOWER  = RADIO_TXPOWER_TXPOWER_0dBm   << RADIO_TXPOWER_TXPOWER_Pos;

    // RF bitrate
    NRF_RADIO->MODE     = RADIO_MODE_MODE_Ble_LR125Kbit       << RADIO_MODE_MODE_Pos; //RADIO_MODE_MODE_Nrf_2Mbit

    // Fast startup mode
    NRF_RADIO->MODECNF0 = (RADIO_MODECNF0_RU_Fast << RADIO_MODECNF0_RU_Pos)|
                          (RADIO_MODECNF0_DTX_Center << RADIO_MODECNF0_DTX_Pos);

    // CRC configuration
    NRF_RADIO->CRCCNF  = RADIO_CRCCNF_LEN_Three << RADIO_CRCCNF_LEN_Pos;
    NRF_RADIO->CRCINIT = 0xFFFFFFUL;      // Initial value
    NRF_RADIO->CRCPOLY = 0x11021UL;     // CRC poly: x^16+x^12^x^5+1

    // Packet format
    NRF_RADIO->PCNF0 =  (0 << RADIO_PCNF0_S0LEN_Pos) | 
                        (0 << RADIO_PCNF0_LFLEN_Pos) | 
                        (0 << RADIO_PCNF0_S1LEN_Pos) | 
                        (RADIO_PCNF0_S1INCL_Include << RADIO_PCNF0_S1INCL_Pos)|
                        (2 << RADIO_PCNF0_CILEN_Pos) |
                        (RADIO_PCNF0_PLEN_LongRange << RADIO_PCNF0_PLEN_Pos)|
                        (RADIO_PCNF0_CRCINC_Exclude << RADIO_PCNF0_CRCINC_Pos)|
                        (3 << RADIO_PCNF0_TERMLEN_Pos);

    NRF_RADIO->PCNF1 = (RADIO_PCNF1_WHITEEN_Disabled     << RADIO_PCNF1_WHITEEN_Pos) |
                       (RADIO_PCNF1_ENDIAN_Big           << RADIO_PCNF1_ENDIAN_Pos)  |
                       (4                                << RADIO_PCNF1_BALEN_Pos)   |
                       (sizeof(sync_pkt_t)               << RADIO_PCNF1_STATLEN_Pos) |
                       (sizeof(sync_pkt_t)               << RADIO_PCNF1_MAXLEN_Pos);
    NRF_RADIO->PACKETPTR = (uint32_t) p_pkt;

    // Radio address config
    NRF_RADIO->PREFIX0 = m_params.rf_addr[0];
    NRF_RADIO->BASE0   = (m_params.rf_addr[1] << 24 | m_params.rf_addr[2] << 16 | m_params.rf_addr[3] << 8 | m_params.rf_addr[4]);

    NRF_RADIO->TXADDRESS   = 0; // use logical address 0 for transmit
    NRF_RADIO->RXADDRESSES = (1 << 0); // enable logical address 0 for receive

    NRF_RADIO->FREQUENCY = m_params.rf_chn;
    NRF_RADIO->TXPOWER   = RADIO_TXPOWER_TXPOWER_Pos4dBm << RADIO_TXPOWER_TXPOWER_Pos;

    NRF_RADIO->EVENTS_END = 0;

    NRF_RADIO->INTENCLR = 0xFFFFFFFF;
    NRF_RADIO->INTENSET = RADIO_INTENSET_END_Msk;

    NVIC_EnableIRQ(RADIO_IRQn);
}

You can find the full project at https://github.com/mdreyercw/nRF5-ble-timesync-demo

From the current consumtion of the transmitting board, it looks like it is sending with 125kBit. Therefore I'm thinking the other bord is unable to recieve or interpret the message.

Thanks and regards

Markus Dreyer

Parents Reply Children
No Data
Related