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

Multiceiver with 3 Devices Using nrf24L01+

I am trying to setup and use the multiceiver scenario. I have setup 4 devices, with one PRX and 3 PTX. I can only get 2 of the PTX to work, but no more. I am aware that by default only Pipe0 and Pipe1 are enabled, and I think I am enabling them all.

Here is my initialization code that works for PTX 1, and PTX 2,but not PTX 3

 // Set radio channel// channel is 7 bits
 Execute(Commands.W_REGISTER, Registers.RF_CH, new[] { (byte)(channel & 0x7F) });

// Set Data 
var regValue = Execute(Commands.R_REGISTER, Registers.RF_SETUP, new byte[1])[1];

 regValue &= (byte)~(1 << Bits.RF_DR_LOW);  // 0
 regValue &= (byte)~(1 << Bits.RF_DR_HIGH); // 0
 // Set data rate
  Execute(Commands.W_REGISTER, Registers.RF_SETUP, new[] { regValue });

  // Enable dynamic payload length
  Execute(Commands.W_REGISTER, Registers.FEATURE, new[] { (byte)(1 << Bits.EN_DPL) });

  // Set auto-ack
  Execute(Commands.W_REGISTER, Registers.EN_AA, new[] { (byte)(1 << Bits.ENAA_P0 | 1 << Bits.ENAA_P1 | 1 << Bits.ENAA_P2 | 1 << Bits.ENAA_P3 | 1 << Bits.ENAA_P4 | 1 << Bits.ENAA_P5) });

// Set dynamic payload length for pipes
Execute(Commands.W_REGISTER, Registers.DYNPD, new[] { (byte)(1 << Bits.DPL_P0 | 1 << Bits.DPL_P1 | 1 << Bits.DPL_P2 | 1 << Bits.DPL_P3 | 1 << Bits.DPL_P4 | 1 << Bits.DPL_P5) });


// Flush RX FIFO
Execute(Commands.FLUSH_RX, 0x00, new byte[0]);

// Flush TX FIFO
Execute(Commands.FLUSH_TX, 0x00, new byte[0]);

// Clear IRQ Masks
 Execute(Commands.W_REGISTER, Registers.STATUS, new[] { (byte)(1 << Bits.MASK_RX_DR | 1 << Bits.MASK_TX_DS | 1 << Bits.MAX_RT) });

// Set default address width
Execute(Commands.W_REGISTER, Registers.SETUP_AW, new[] { AddressWidth.Get(address) });

//Enable Pipes 0, 1, 2
 Execute(Commands.W_REGISTER, Registers.EN_RXADDR, new[] { (byte)(1 << Bits.ERX_P0 | 1 << Bits.ERX_P1 | 1 << Bits.ERX_P2 ) });

Execute(Commands.W_REGISTER, Registers.RX_ADDR_P0, _slot0Address);//Pipe 0  unique Address
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P1, Encoding.UTF8.GetBytes(BaseAddress + 1));
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P2, Encoding.UTF8.GetBytes(BaseAddress + 2));

// Set retransmission values
Execute(Commands.W_REGISTER, Registers.SETUP_RETR, new[] { (byte)(0x0F << Bits.ARD | 0x0F << Bits.ARC) });


Execute(Commands.W_REGISTER, Registers.RX_ADDR_P0, _slot0Address);
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P1, Encoding.UTF8.GetBytes(BaseAddress + 1));
Execute(Commands.W_REGISTER, Registers.RX_ADDR_P2, Encoding.UTF8.GetBytes(BaseAddress + 2));

Execute(Commands.W_REGISTER, Registers.CONFIG, new[] { (byte)(1 << Bits.PWR_UP | 1 << Bits.CRCO | 1 << Bits.PRIM_RX) });
Parents
  • Ok, problem solved. I was doing 2 things wrong, and I missed it somehow in the documentation.

    1. The LSByte issue - I was using addresses in form base + 1, base + 2, etc and should have used 1 + base, 2 + base to generate the pipe1-5 addresses.

    2. More importantly, I missed the fact that addresses 2-5 are only 1 byte, and not 5 as the rest, so I was setting addresses in the form above, but for pipe address 2-5, I should have only used the 1, 2, 3 etc and not include the base in it.

Reply
  • Ok, problem solved. I was doing 2 things wrong, and I missed it somehow in the documentation.

    1. The LSByte issue - I was using addresses in form base + 1, base + 2, etc and should have used 1 + base, 2 + base to generate the pipe1-5 addresses.

    2. More importantly, I missed the fact that addresses 2-5 are only 1 byte, and not 5 as the rest, so I was setting addresses in the form above, but for pipe address 2-5, I should have only used the 1, 2, 3 etc and not include the base in it.

Children
No Data
Related