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,

    Thanks I going to try it soon, and yame back if something is still wrong.

  • Dear Hakon, Unfortunatelly my problem is still exist. Here it is my settings: PTX pipe 0: TX_ADDRESS[3] ={11,11,11} ; RX_ADDRESS[3] ={11,11,11} ; RX_ADDRP0 = TX_ADDR; 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); //enable P0 datapipe etc...

    PTX1 pipe 1 config: TX_ADDRESS[3] ={11,11,22} ; RX_ADDRESS[3] ={11,11,22} ;

    RX_ADDRP0 = TX_ADDR; 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); //enable P0 datapipe etc...

    PRX config:

    RX_ADDRESS[3] ={11,11,11} ; //Pipe 0 RX_ADDRESS_1 [3] ={11,11,22} ; //Pipe 1

    RX_ADDRP0 = TX_ADDR; 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 ); //RX pipe0 addres rf_write_register(RX_ADDR_P1,RX_ADDRESS_1,3 );//RX pipe1 address

  • Are you still having issues with this?

    Are you setting the EN_AA and EN_RXADDR register properly on the PRX? It seems that you are first enabling PIPE0, then clearing this and enabling PIPE1. EN_AA should be 0x03 & EN_RXADDR should be 0x03 in order to receive on PIPE0 and PIPE1.

  • 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) ;

  • You should not set the EN_AA register bit-wise. You will then overwrite the previous value. Set it like this instead: "rf_config_register(EN_AA, (1 << enaa_p0)|(1 << enaa_p1));"

    Same goes for EN_RXADDR register.

Related