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

nrf24l01 multiple pipes

Dear Tech support,

I spend couple month with discovering your nice nrd24l01 chip. Most of the things working correctly, but till know I just used two modul as a single PTX and PRX for comunication on pipe 0. Now I wan't to use 3 ptx and one prx. I have red the documentation how I have to give the PTX addresses and the PRX adresses, I try to follow it but somehow It doesn't work. Now the only way to use more PTC with one PRX to use different frequence and change the PRX side the chanel during the listening/ receiving.

I use only 3 byte addresses. Lets see it first:

PTX2 Pipe 1 init not full only the relevant parts:

Code:

unsigned char TX_ADDRESS[3] ={11,11,22} ; unsigned char RX_ADDRESS[3] ={11,11,22} ; rf_write_register(RX_ADDR_P1,RX_ADDRESS,3 ); rf_write_register(TX_ADDR,TX_ADDRESS,3 ); rf_config_register(EN_RXADDR,1<<ERX_P1); v=0x03; rf_config_register(RX_PW_P1,v);

PTX1 Pipe 0 init not full only the relevant parts:

Code:

unsigned char TX_ADDRESS[3] ={11,11,11} ; unsigned char RX_ADDRESS[3] ={11,11,11} ; rf_write_register(RX_ADDR_P0,RX_ADDRESS,3 ); rf_write_register(TX_ADDR,TX_ADDRESS,3 ); rf_config_register(EN_RXADDR,1<<ERX_P0); v=0x03; rf_config_register(RX_PW_P0,v);

PRX Pipe init not full only the relevant parts:

Code:

unsigned char TX_ADDRESS[3] ={11,11,11} ; unsigned char RX_ADDRESS[3] ={11,11,11} ; unsigned char RX_ADDRESS_1 [3] ={11,11,22} ;

rf_write_register(RX_ADDR_P0,RX_ADDRESS,3 ); rf_write_register(RX_ADDR_P1,RX_ADDRESS_1,3 ); rf_write_register(TX_ADDR,TX_ADDRESS,3 ); rf_config_register(EN_RXADDR,1<<ERX_P0); v=0x03 ; rf_config_register(RX_PW_P0,v) ; rf_config_register(RX_PW_P1,v) ;

PRX receivig code only:

Code:

if (IRQ_source !=0 ) //van vett adat ? {

       data=rf_read_payload(3) ; 
     for(i=0;i<3;i++)
     {

uart_sendbyte(data[i]); }

     IRQ_source=0x00 ;

switch (data_pipe) { case 0: { uart_sendbyte(data_pipe); // send pipe number rf_config_register(EN_RXADDR,0x02); //P0 datapipe disable P1 datapipe enable break; } case 1: { uart_sendbyte(data_pipe); rf_config_register(EN_RXADDR,0x01); //P1 datapipe disable P0 datapipe enable break; } default : uart_sendbyte(data_pipe);

}

data_pipe is unsigned char variable global and read during interrupt rutin:

Code:

a=rf_read_register1(STATUS); data_pipe=a; data_pipe=data_pipe&0x0f; data_pipe=data_pipe>>1; //because upper 3 byte valid

My first question when I should enable the pipe 0 and pipe 1.

If I enabled both during initialization comunication never builded up. If I do it on this way the communication also never builded up.

What is the right methode for it?

  • Dear Hakon,

    My problem is still exist. I modified my code in severall places. Please see fisrt my Inits:

    PTX Pipe TX_ADDRESS[3] ={11,11,11} ; RX_ADDRESS[3] ={11,11,11} ; RX_ADDRP0 = TX_ADDR rf_config_register(EN_AA,1<<ENAA_P0); rf_write_register(RX_ADDR_P0,RX_ADDRESS,3 ); //RX address rf_write_register(TX_ADDR,TX_ADDRESS,3 ); //TX address rf_config_register(EN_RXADDR,1<<ERX_P0);

    PTX 2 pipe 1 only the TX address and RX adress are different: TX_ADDRESS[3] ={11,11,22} ; RX_ADDRESS[3] ={11,11,22} ; Everything is the same.

    PRX init: TX_ADDRESS[3] ={11,11,11} ; //Pipe 0 RX_ADDRESS[3] ={11,11,11} ; //Pipe 0 RX_ADDRESS_1 [3] ={11,11,22} ; //Pipe 1 rf_config_register(EN_AA,1<<ENAA_P0); //pipe 0 ack enable rf_config_register(EN_AA,1<<ENAA_P1); //pipe 1 ack enable rf_write_register(RX_ADDR_P0,RX_ADDRESS,3 );
    rf_write_register(RX_ADDR_P1,RX_ADDRESS_1,3 ); rf_config_register(RX_PW_P0,v) ; rf_config_register(RX_PW_P1,v) ;

  • On the PRX init, you are still overwriting the EN_AA register. This register should be set to 0x03: rf_config_register(EN_AA, (1 << ENAA_P0) | (1 << ENAA_P1) );

  • Dear Hakon, I corrected but i just can receive only pipe 1. Pipe 0 not. PRX config: rf_config_register(EN_AA,1<<ENAA_P0 | ENAA_P1 ); rf_write_register(RX_ADDR_P0,RX_ADDRESS,3 );
    rf_write_register(RX_ADDR_P1,RX_ADDRESS_1,3 ); rf_config_register(EN_RXADDR,1<<ERX_P0 | 1<<ERX_P1); is it ok ? v=0x03 ; rf_config_register(RX_PW_P0,v) ; rf_config_register(RX_PW_P1,v) ;

    PTX pipe 0 : rf_config_register(EN_AA,1<<ENAA_P0); is it ok ? rf_write_register(RX_ADDR_P0,RX_ADDRESS,3 ); rf_write_register(TX_ADDR,TX_ADDRESS,3 ); rf_config_register(EN_RXADDR,1<<ERX_P0); //pipe 0 v=0x03; rf_config_register(RX_PW_P0,v); PTX pipe 1 config: rf_config_register(EN_AA,1<<ENAA_P1); f_write_register(RX_ADDR_P1,RX_ADDRESS,3 ); rf_write_register(TX_ADDR,TX_ADDRESS,3 ); rf_config_register(EN_RXADDR,1<<ERX_P1); v=0x03; rf_config_register(RX_PW_P1,v); Only pipe 1 received on PRX. Pipe 0 never received

Related