AnsweredAssumed Answered

nrf24l01 sending from f3 to f0 discovery

Question asked by zrim.urban on May 18, 2015
Hello!
I'm trying to pair two nrf24l01 with f3 and f0 discovery boards. I've checked all the registers and they are initialized correctly, but I still can't receive anything. I don't have access to a spectrum analyser, so I'm asking for your help, if there are some things I'm missing out.

Thank you in advance!

Receiver code: (I didn't paste the discovery's initialization code above)

    int i = 0;
    uint8_t rec = 0;
    uint8_t buf[10];
 
    uint8_t test = 0;
 
    setRX();
 
    while(1)
    {
 
        nrf24_flushRX();
        nrf24_WriteByte(NRF24_CONFIG, 0x0f);
        NRF24_CE_LOW();
        rec = nrf24_ReadByte(NRF24_STATUS);
        if(rec & 0x40){
            nrf24_ReadPayload(NRF24_R_RX_PAYLOAD, buf, 32);
        }
 
        NRF24_CE_HIGH();
 
        nrf24_WriteByte(NRF24_STATUS, 0x40);
 
    }
}
 
 
void setRX(void){
 
    int rec = 0;
    uint8_t str[15];
    uint8_t tx_address[5] = {0xe7, 0xe7, 0xe7, 0xe7, 0xe7};
    uint8_t rx_address[5] = {0x7e, 0x7e, 0x7e, 0x7e, 0x7e};
 
    NRF24_CE_LOW();
    nrf24_WriteMultipleBytes(NRF24_RX_ADDR_P1, rx_address, 5);
    nrf24_WriteMultipleBytes(NRF24_RX_ADDR_P0, tx_address, 5);
    nrf24_WriteMultipleBytes(NRF24_TX_ADDR, tx_address, 5);
 
    nrf24_WriteByte(NRF24_RX_PW_P0, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P1, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P2, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P3, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P4, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P5, 0x20);
 
    nrf24_WriteByte(NRF24_RF_CH, 15);
    nrf24_WriteByte(NRF24_RF_SETUP, 0x06);
    nrf24_WriteByte(NRF24_EN_AA, 0x3f);
    rec = nrf24_ReadByte(NRF24_RF_CH);
    nrf24_WriteByte(NRF24_SETUP_RETR, 0x4f);
    nrf24_WriteByte(NRF24_EN_RXADDR, 0x3f);
    nrf24_WriteByte(NRF24_DYNPD, 0x00);
    nrf24_WriteByte(NRF24_CONFIG, 0x0f);    //SPI is available in power down mode, although radio can't transmit
    NRF24_CE_HIGH();
}

Transmitter code:

    int i = 0;
    uint8_t rec = 0;
    uint8_t buf[10];
 
    uint8_t test = 0;
 
    setRX();
 
    uint8_t dataOut[32];
    while(1)
    {
        sprintf((char *)dataOut, "abcdefghijklmno");
        i = 150;
        nrf24_WriteByte(NRF24_CONFIG, 0x0e);
        nrf24_flushTX();
        NRF24_CE_LOW();
        nrf24_WritePayload(NRF24_W_TX_PAYLOAD, dataOut, 32);
        NRF24_CE_HIGH();
        while(i--);
        nrf24_WriteByte(NRF24_STATUS, 0x20);
 
    }
}
 
 
void setRX(void){
 
    int rec = 0;
    uint8_t str[15];
    uint8_t rx_address1[5] = {0xe7, 0xe7, 0xe7, 0xe7, 0xe7};
    uint8_t tx_address[5] = {0x7e, 0x7e, 0x7e, 0x7e, 0x7e};
 
    NRF24_CE_LOW();
    nrf24_WriteMultipleBytes(NRF24_RX_ADDR_P1, rx_address1, 5);
    nrf24_WriteMultipleBytes(NRF24_RX_ADDR_P0, tx_address, 5);
    nrf24_WriteMultipleBytes(NRF24_TX_ADDR, tx_address, 5);
 
    nrf24_WriteByte(NRF24_RX_PW_P0, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P1, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P2, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P3, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P4, 0x20);
    nrf24_WriteByte(NRF24_RX_PW_P5, 0x20);
 
    nrf24_WriteByte(NRF24_RF_CH, 15);
    nrf24_WriteByte(NRF24_RF_SETUP, 0x06);
    nrf24_WriteByte(NRF24_EN_AA, 0x3f);
    rec = nrf24_ReadByte(NRF24_RF_CH);
    nrf24_WriteByte(NRF24_SETUP_RETR, 0x4f);
    nrf24_WriteByte(NRF24_EN_RXADDR, 0x3f);
    nrf24_WriteByte(NRF24_DYNPD, 0x00);
    nrf24_WriteByte(NRF24_CONFIG, 0x0e);    //SPI is available in power down mode, although radio can't transmit
    NRF24_CE_HIGH();
 
}

Outcomes