Jump to content
43oh

Nrf24l01+ Pipe Addressingad


Recommended Posts

Hello I have been trying to implement multiceiver on nrf24l01 and msp430g2553. Basically I am trying to use different pipes for the same rf channel. The library and the example code I am using is the spirilis one, one of the most common. The problem is that I can only work with the default pipe 0 given in the code when ever I try to use the other pipes I can't get anything. I read the datasheet about the multiceiver part, I guess I understand both the code and the working mechanism but I still can't use the different pipes. Any help would be appreciated.

 

What I do is that; at first by using msprf24_set_pipe_packetsize() and msprf24_open_pipe functions I set the pipe I would like to use which is from 0 to 5. Then I try for the given addresses on both tx and rx I set it to same pipe number and the same pipe address but only the default(one I posted here) works for the pipe 0 and that given address. 

Link to post
Share on other sites

I have figured out the problem the array named addr which actually represents the 5 byte of the address of the pipe#0. So in order to use the second or the third pipe for instance some other array which consist some other pipe address must be initialized and used. I am posting the code I'm now using for piping so that anyone can benefit, the library I use is the spirilis as I mentioned. 

//TRANSMITTER//

#include <msp430.h>
#include "msprf24.h"
#include "nrf_userconfig.h"
#include "stdint.h"

int scan[5];
volatile unsigned int user;
unsigned char isalive;
int i  = 0;
unsigned int chan;
unsigned char buf[32] = {'h','e','l','l','o'};
unsigned char *ptrbuf = "hello";

int pipe_test;

void main()
{
	uint8_t addr0[5];
	uint8_t addr1[5];
	uint8_t addr2[5];

	WDTCTL = WDTHOLD | WDTPW;
	DCOCTL = CALDCO_16MHZ;
	BCSCTL1 = CALBC1_16MHZ;	
	BCSCTL2 = DIVS_1;  		


	P1DIR |= 0x41;		
	P1OUT &= ~0x41;

	user = 0xFE;

	
	rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit
	rf_addr_width      = 5;
	rf_speed_power     = RF24_SPEED_1MBPS | RF24_POWER_0DBM;
	rf_channel         = 120;


	msprf24_init();  
	msprf24_set_pipe_packetsize(2, 32);
	msprf24_open_pipe(2, 0); 
        
	msprf24_standby();
	user = msprf24_current_state();

	addr0[0] = 0xE7;	addr0[1] = 0xD3;	addr0[2] = 0xF0;	addr0[3] = 0x35;	addr0[4] = 0x77;
	addr1[0] = 0xC2;	addr1[1] = 0xC2;	addr1[2] = 0xC2;	addr1[3] = 0xC2;	addr1[4] = 0xA1;
	addr2[0] = 0xC2;	addr2[1] = 0xC2;	addr2[2] = 0xC2;	addr2[3] = 0xC2;	addr2[4] = 0xF1;

	w_tx_addr(addr2);
	w_rx_addr(2, addr2);  
			           
	isalive = msprf24_is_alive();
	pipe_test = msprf24_pipe_isopen(2);

	while(1){
		__delay_cycles(800000);

		w_tx_payload(32, buf);
		msprf24_activate_tx();
		LPM4;

		if (rf_irq & RF24_IRQ_FLAGGED) {
			rf_irq &= ~RF24_IRQ_FLAGGED;

			msprf24_get_irq_reason();
			if (rf_irq & RF24_IRQ_TX){
				P1OUT &= ~BIT0; // Red LED off
				P1OUT |= 0x40;  // Green LED on
			}
			if (rf_irq & RF24_IRQ_TXFAILED){
				P1OUT &= ~BIT6; // Green LED off
				P1OUT |= BIT0;  // Red LED on
			}


			msprf24_irq_clear(rf_irq);
			user = msprf24_get_last_retransmits();
		}
	}

}

#include <msp430.h>
#include "msprf24.h"
#include "nrf_userconfig.h"
#include "stdint.h"

unsigned char isalive;
volatile unsigned int user;
unsigned int scan,scan1;
int pipe_test;
unsigned char buf[32];

int main()
{
	uint8_t addr0[5];
	uint8_t addr1[5];
	uint8_t addr2[5];


	WDTCTL = WDTHOLD | WDTPW;
	DCOCTL = CALDCO_16MHZ;
	BCSCTL1 = CALBC1_16MHZ;	 	
	BCSCTL2 = DIVS_1; 			

	P1DIR |= BIT0+BIT6;
	P1OUT &= ~(BIT0+BIT6);

	user = 0xFE;

	rf_crc = RF24_EN_CRC | RF24_CRCO; // CRC enabled, 16-bit
	rf_addr_width      = 5;
	rf_speed_power     = RF24_SPEED_1MBPS  | RF24_POWER_0DBM ;
	rf_channel         = 120;

msprf24_set_channel();

	msprf24_init();
	msprf24_set_pipe_packetsize(2, 32);
	msprf24_open_pipe(2, 0);

	
	addr0[0] = 0xE7;	addr0[1] = 0xD3;	addr0[2] = 0xF0;	addr0[3] = 0x35;	addr0[4] = 0x77;
	addr1[0] = 0xC2;	addr1[1] = 0xC2;	addr1[2] = 0xC2;	addr1[3] = 0xC2;	addr1[4] = 0xA1;
	addr2[0] = 0xC2;	addr2[1] = 0xC2;	addr2[2] = 0xC2;	addr2[3] = 0xC2;	addr2[4] = 0xF1;




	w_rx_addr(2, addr2);

	if (!(RF24_QUEUE_RXEMPTY & msprf24_queue_state())) {
		flush_rx();
	}
	msprf24_activate_rx();
	LPM4;

	isalive = msprf24_is_alive();
	pipe_test = msprf24_pipe_isopen(2);


	while (1) {
		if (rf_irq & RF24_IRQ_FLAGGED) {
			rf_irq &= ~RF24_IRQ_FLAGGED;
			msprf24_get_irq_reason();
		}
		if (rf_irq & RF24_IRQ_RX || msprf24_rx_pending()) {
			r_rx_payload(32, buf);
			msprf24_irq_clear(RF24_IRQ_RX);
			user = buf[0];

			if (buf[0] == '0')
				P1OUT &= ~BIT0;
			if (buf[0] == '1')
				P1OUT |= BIT0;
			if (buf[1] == '0')
				P1OUT &= ~BIT6;
			if (buf[1] == '1')
				P1OUT |= BIT6;

		} else {
			user = 0xFF;
		}


		LPM4;
	}
	return 0;
}

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...