Ive been working on this for some time and can not get two boards successfully communicating using the 125Kbps on the NRF52840. I am simply having one chip transmit advertising packets, and the other receive them. It is working for 1Mbps and 2Mbps, but I can not get 125Kbps working. Im assuming I should just have to change the radio configuration and the rest of the code should work, correct? I have tried working with the following examples.
https://devzone.nordicsemi.com/f/nordic-q-a/22094/rx-on-le-coded-phy
Here is my working code for 1Mbit. Any chance I could get some help on getting this to work with 125Kbps?
#define PACKET_S1_FIELD_SIZE (0UL) /**< Packet S1 field size in bits. */ #define PACKET_S0_FIELD_SIZE (0UL) /**< Packet S0 field size in bits. */ #define PACKET_LENGTH_FIELD_SIZE (0UL) /**< Packet length field size in bits. */ #define PACKET_BASE_ADDRESS_LENGTH (4UL) //!< Packet base address length field size in bytes #define PACKET_STATIC_LENGTH (1UL) //!< Packet static length in bytes #define PACKET_PAYLOAD_MAXSIZE (PACKET_STATIC_LENGTH) //!< Packet payload maximum size in bytes #define CRC_POLYNOMIAL_INIT_SETTINGS ((0x5B << 0) | (0x06 << 8) | (0x00 << 16)) uint8_t access_address[4] = {0xD6, 0xBE, 0x89, 0x8E}; uint8_t seed[3] = {0x55, 0x55, 0x55}; void radio_configure(uint8_t *p_data) { NRF_RADIO->POWER = RADIO_POWER_POWER_Disabled << RADIO_POWER_POWER_Pos; NRF_RADIO->POWER = RADIO_POWER_POWER_Enabled << RADIO_POWER_POWER_Pos; NRF_RADIO->FREQUENCY = 2UL; NRF_RADIO->SHORTS = 0; NRF_RADIO->TXPOWER = (RADIO_TXPOWER_TXPOWER_Pos8dBm << RADIO_TXPOWER_TXPOWER_Pos); NRF_RADIO->MODE = (RADIO_MODE_MODE_Ble_1Mbit << RADIO_MODE_MODE_Pos); // Radio address config 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) ); NRF_RADIO->RXADDRESSES = 0x01UL; 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); 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)37) << RADIO_PCNF1_MAXLEN_Pos) & RADIO_PCNF1_MAXLEN_Msk) | ((RADIO_PCNF1_WHITEEN_Enabled << RADIO_PCNF1_WHITEEN_Pos) & RADIO_PCNF1_WHITEEN_Msk); NRF_RADIO->TIFS = 150; // CRC Config 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); NRF_RADIO->CRCINIT = ((uint32_t)seed[0]) | ((uint32_t)seed[1])<<8 | ((uint32_t)seed[2])<<16; //match ID code NRF_RADIO->DAB[0]= 0; NRF_RADIO->DAP[0]= 0; NRF_RADIO->DACNF = 0; //first packet in buffer NRF_RADIO->PACKETPTR = (uint32_t)&(p_data[0]); //radio should be configured at this point. Power it up. NRF_RADIO->EVENTS_READY = 0U; //clear the read flad // Enable radio and wait for ready NRF_RADIO->TASKS_RXEN = 1U; while (NRF_RADIO->EVENTS_READY == 0U) { // wait } NRF_RADIO->EVENTS_END = 0U; //radio ready, clear flag //ready! run this next line from main //NVIC_EnableIRQ(RADIO_IRQn); //NRF_RADIO->TASKS_START = 1U; // Start listening and wait for address received event }