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

NRF52840 radio Receiver recognizing problem with nrf24l0+ transmitter

Hi 

I am new to the NRF52840. I am trying to receive data from nrf24L01+ to the nrf52840 Development kit. I find some examples from the SDK radio receiver using PCAl0056. I think I need to match the transmitter address and receiver address and rf channel for receiving some packets. I find from the tutorial with base and prefix adddress. But I couldn't understand how I will add that in the program. my Nrf24l01+ is working in tx mode with address 

unsigned char rxAddress[5] = { 0xA7, 0x5B, 0xCD, 0x14, 0x15 };
unsigned char txAddress[5] = { 0xA7, 0x5B, 0xCD, 0x14, 0x15 };
unsigned char nRFReceiveBuffer[32];

char InitializeNRF_1 (nrf24l01_dev* dev)
{

dev->BUSY_FLAG = 0;
dev->ADDR_WIDTH = NRF_ADDR_WIDTH_3;
dev->CRC_WIDTH = NRF_CRC_WIDTH_1B;
dev->DATA_RATE = NRF_DATA_RATE_250KBPS;
dev->NRF_CE_GPIO_PIN = GPIO_PIN_8;
dev->NRF_CE_GPIOx = GPIOA;
dev->NRF_CSN_GPIO_PIN = GPIO_PIN_4;
dev->NRF_CSN_GPIOx = GPIOA;
dev->NRF_IRQ_GPIO_PIN = GPIO_PIN_0;
dev->NRF_IRQ_GPIOx = GPIOA;
dev->NRF_IRQ_preempt_priority = 0;
dev->NRF_IRQ_sub_priority = 0;
dev->NRF_IRQn = EXTI0_1_IRQn;
dev->PayloadLength = 32;
dev->RetransmitCount = 0;
dev->RetransmitDelay = 0;
dev->RF_CHANNEL = 100;
dev->RX_ADDRESS = rxAddress;
dev->RX_BUFFER = nRFReceiveBuffer;
dev->spi = &spi;
dev->STATE = NRF_STATE_TX;
dev->TX_ADDRESS = txAddress;
dev->TX_BUFFER = (uint8_t*)cipherText;
dev->TX_POWER = NRF_TX_PWR_0dBm;
dev->RX_BUFFER_BYTE_COUNT = 0;

if (NRF_Init(dev) == NRF_OK)
return 1;
else
return 0;
}

Could you please help me to explain it little bit breifly?

  • I tried it like this,but I always receive 0 payload and crc is incorrect. Is something wrong with this code? How to correct the crc to receive the packets..

    void RadioEnable()
    {
    // All radio registers are reset when the peripheral is powered off/on.
    NRF_RADIO->POWER = 1;
    }

    void radio_receiver()
    {
    uint8_t rxAddress[5] = { 0xA7, 0x5B, 0xCD, 0x14, 0x15 };


    #define RADIO_MODE_MODE_Nrf_250Kbit (2UL)

    uint32_t myBaseAddress;
    myBaseAddress=(((uint32_t)rxAddress[1])<<24)|(((uint32_t)rxAddress[2])<<16)|(((uint32_t)rxAddress[3])<<8)|((uint32_t)rxAddress[4]); //target base address

    NRF_RADIO->BASE0=myBaseAddress;
    NRF_RADIO->PREFIX0=rxAddress[0];
    NRF_RADIO->FREQUENCY = 100UL;
    NRF_RADIO->MODE = (RADIO_MODE_MODE_Nrf_250Kbit << RADIO_MODE_MODE_Pos);
    NRF_RADIO->PCNF1 =0x42020 ;//Means: base address is 4 bytes long (possible range is 2 to 4) and max size of payload is 32,and 32bytes of static length payload
    NRF_RADIO->PCNF0=0;//S0,LENGTH, and S1 are all zero bits long.
    NRF_RADIO->MODECNF0=1; //enable fast ramp-up of radio from DISABLED state.
    NRF_RADIO->CRCCNF=1; // CRC is is 1 bytes and is computed including the address field
    NRF_RADIO->TXPOWER = (RADIO_TXPOWER_TXPOWER_0dBm << RADIO_TXPOWER_TXPOWER_Pos);
    NRF_RADIO->TXADDRESS = 0x00UL;
    NRF_RADIO->RXADDRESSES = 0x01UL;
    NRF_RADIO->PACKETPTR=(uint32_t)rxBuffer;//put the received payload in rxBuffer


    NRF_LOG_INFO("Radio receiver example started.");
    NRF_RADIO->TASKS_DISABLE=1; //sleep the radio
    while (NRF_RADIO->STATE) {}; //wait until radio is DISABLED (i.e. STATE=0);
    NRF_RADIO->TASKS_RXEN=1; //turn on the radio receiver and enter into state RXIDLE
    while (!(NRF_RADIO->EVENTS_READY))
    {
    NRF_LOG_INFO("Wait for first packet"); //Busy-wait. After event READY, radio shall be in state RXIDLE.
    }
    if(NRF_RADIO->EVENTS_READY == 1U)
    {
    NRF_RADIO->TASKS_START=1U; //Move from RXIDLE mode into RX mode.
    NRF_LOG_INFO("Nrf radio is ready to receive");
    if ((NRF_RADIO->CRCSTATUS == 1U))
    {
    NRF_LOG_INFO("crc correct");
    }
    else
    {
    NRF_LOG_INFO("crc incorrect");
    }
    for(int i=0;i<32;i++)
    {

    NRF_LOG_INFO("Payload Received! Payload= %02x\n",rxBuffer[i]);

    }
    }
    NRF_LOG_FLUSH();
    }

  • Hi,

    NRF_DATA_RATE_250KBPS is not supported on the nRF52840. See product spec. I am sorry for the inconvenience.

Related