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

nRF24L01+ Pipe2 to Pipe5 not working.

In an RFID application, we have nrf24l01+ and SMT32F4xx on the Reader and nrf24lu1+ on the tag.

The Reader is acting as multiceiver currently.

Pipe 0 and Pipe 1 are working fine. We have problem with Pipe 2 to Pipe 5.

RF channel is 2 , payload is 10, 250Kbps data rate.

Following is the register dump on the Reader: RX_ADDR_P0 = e7 e7 e7 e7 e7, RX_ADDR_P1 = e1 e1 e1 e1 e0, RX_ADDR_P2 = d2, RX_ADDR_P3 = c3, RX_ADDR_P4 = b4, RX_ADDR_P5 = a5, CONFIG = b, EN_AA = 3f, EN_RXADDR = 3f, SETUP_AW = 3, SETUP_RETR = 4f, RF_CH = 2, RF_SETUP = 26, RX_PW_P0 = a, RX_PW_P1 = a, RX_PW_P2 = a, RX_PW_P3 = a, RX_PW_P4 = a, RX_PW_P5 = a.

Rgds, Pradeep

  • Hi Pradeep,

    I would need to see your code for configuration on both side receiver and transmitter. Have you tried to test with our nRFGO SDK's examples ?

  • For the tag as transmitter, we have used nRFGO SDK's example. For Reader as receiver, please check below code.

    Reader Code:

    uint8_t rx1_address[5] = {0xE1, 0xE1, 0xE1, 0xE1, 0xE0};
    uint8_t rx2_address[1] = { 0xD2 };
    uint8_t rx3_address[1] = { 0xC3 };
    uint8_t rx4_address[1] = { 0xB4 };
    uint8_t rx5_address[1] = { 0xA5 };
    volatile uint8_t IRQ1 = 0;
    
        void main()
     {
    // init hardware pins 
        nrf24_init();
    
    // Set the device addresses 
            nrf24_rx1_address(rx1_address);  // RX_ADDR_P1. E1E1E1E1E0
    	nrf24_rx2_address(rx2_address);  // RX_ADDR_P2  		D2
    	nrf24_rx3_address(rx3_address);  // RX_ADDR_P3  		C3
    	nrf24_rx4_address(rx4_address);  // RX_ADDR_P4  		B4
    	nrf24_rx5_address(rx5_address);  // RX_ADDR_P5  		A5
    
    	// Channel #2 , payload length: 10 
            nrf24_config(2,10);
    
         while(1)
        {
             if(IRQ1 == 1)
    		{
    			 IRQ1 = 0; 
    
    			 if(nrf24_dataReady())
    				  {
    					nrf24_getData(data_array);
    					  APP_PRINTF(" Antenna 1 =  ");  
    					  APP_PRINTF("%s",data_array);
    					APP_PRINTF("\r\n");
    				  }
    
                   }
          }
    }      
    
    void nrf24_config(uint8_t channel, uint8_t pay_length)
    {
        /* Use static payload length ... */
        payload_len = pay_length;
    
        // Set RF channel
        nrf24_configRegister(RF_CH,channel);
    
        // Set length of incoming payload 
           nrf24_configRegister(RX_PW_P0, payload_len); // Auto-ACK pipe ... added
    	nrf24_configRegister(RX_PW_P1, payload_len); // Data payload pipe
        nrf24_configRegister(RX_PW_P2, payload_len); // Pipe used 
        nrf24_configRegister(RX_PW_P3, payload_len); // Pipe used 
        nrf24_configRegister(RX_PW_P4, payload_len); // Pipe used 
        nrf24_configRegister(RX_PW_P5, payload_len); // Pipe used 
    
        // 250 Kbps, TX gain: 0dbm
    	 nrf24_configRegister(RF_SETUP, 0x26);
    	
        // CRC enable, 1 byte CRC length
        nrf24_configRegister(CONFIG,nrf24_CONFIG);
    
    	nrf24_configRegister(EN_AA,(1<<ENAA_P0)|(1<<ENAA_P1)|(1<<ENAA_P2)|(1<<ENAA_P3)|(1<<ENAA_P4)|(1<<ENAA_P5));  // added
    
    	nrf24_configRegister(EN_RXADDR,(1<<ERX_P0)|(1<<ERX_P1)|(1<<ERX_P2)|(1<<ERX_P3)|(1<<ERX_P4)|(1<<ERX_P5)); // added
    
    	
        // Auto retransmit delay: 1000 us and Up to 15 retransmit trials
        nrf24_configRegister(SETUP_RETR,(0x04<<ARD)|(0x0F<<ARC));
    
        // Dynamic length configurations: No dynamic length
        nrf24_configRegister(DYNPD,(0<<DPL_P0)|(0<<DPL_P1)|(0<<DPL_P2)|(0<<DPL_P3)|(0<<DPL_P4)|(0<<DPL_P5));
    
        // Start listening
        nrf24_powerUpRx();
    }
           
    
    /* Set the RX address */
    void nrf24_rx1_address(uint8_t * adr) 
    {
        nrf24_ce_digitalWrite(LOW);
        nrf24_writeRegister(RX_ADDR_P1,adr,5);
        nrf24_ce_digitalWrite(HIGH);
    }
    
    /* Set the RX address */
    void nrf24_rx2_address(uint8_t * adr) 
    {
        nrf24_ce_digitalWrite(LOW);
        nrf24_writeRegister(RX_ADDR_P2,adr,1);
        nrf24_ce_digitalWrite(HIGH);
    }
    
    /* Set the RX address */
    void nrf24_rx3_address(uint8_t * adr) 
    {
        nrf24_ce_digitalWrite(LOW);
        nrf24_writeRegister(RX_ADDR_P3,adr,1);
        nrf24_ce_digitalWrite(HIGH);
    }
    
    /* Set the RX address */
    void nrf24_rx4_address(uint8_t * adr) 
    {
        nrf24_ce_digitalWrite(LOW);
        nrf24_writeRegister(RX_ADDR_P4,adr,1);
        nrf24_ce_digitalWrite(HIGH);
    }
    
    /* Set the RX address */
    void nrf24_rx5_address(uint8_t * adr) 
    {
        nrf24_ce_digitalWrite(LOW);
        nrf24_writeRegister(RX_ADDR_P5,adr,1);
        nrf24_ce_digitalWrite(HIGH);
    }
    /* Checks if data is available for reading */
    /* Returns 1 if data is ready ... */
    uint8_t nrf24_dataReady() 
    {
        // See note in getData() function - just checking RX_DR isn't good enough
        uint8_t status = nrf24_getStatus();
    
        // We can short circuit on RX_DR, but if it's not set, we still need
        // to check the FIFO for any pending packets
        if ( status & (1 << RX_DR) ) 
        {
            return 1;
        }
    
        return !nrf24_rxFifoEmpty();;
    }
    
    /* Reads payload bytes into data array */
    void nrf24_getData(uint8_t* data) 
    {
        /* Pull down chip select */
        nrf24_csn_digitalWrite(LOW);                               
    
        /* Send cmd to read rx payload */
        SPI1_send( R_RX_PAYLOAD );
        
        /* Read payload */
        nrf24_transferSync(data,data,payload_len);
        
        /* Pull up chip select */
        nrf24_csn_digitalWrite(HIGH);
    
        /* Reset status register */
        nrf24_configRegister(STATUS,(1<<RX_DR));   
    }
    

    Tag code (Transmitter):

    #ifdef MCU_NRF24LE1
    #include "nrf24le1.h"
    #include "hal_clk.h"
    #endif
    
    #ifdef MCU_NRF24LU1P
    #include "nrf24lu1p.h"
    #endif
    
    #include <stdint.h>
    #include <stdbool.h>
    #include "cpu.h"
    #include "hal_nrf.h"
    #include "hal_uart.h"
    #include "hal_delay.h"
    #include "cklf.h"  
    #include <string.h>
    
    #ifndef MCU_NRF24LU1P
    #include "hal_clk.h" //lint !e322 !e7 "include file not found"
    #endif
    
    
    // Global variables
    static bool volatile radio_busy;
    static bool volatile radio_transmit;
    
    	uint8_t TX_addr[5] = {0xE1,0xE1,0xE1,0xE1,0xD2}; // for Tag 1
    	
    	uint8_t payload[10] = {'6','1','2','0','0','0','0','0','9','7'};    //payload for testing 1234567899  Tag 2
    	//uint8_t payload[10] = {'1','2','3','4','4','4','4','4','5','6'};    //payload for testing 1234444456 Tag 1
    
    		
    uint16_t Buzzer_loop=0,Checkout=0;
    uint8_t Fstate=0;
    	
    void main(void)
    {	
    	CLKCTL=0x80;     // system clock 16 Mhz
    
    	
    // Buzzer Configurations	
    	
    	P0DIR &= ~(1 << 4);  // P0.4 Buzzer as output(TP-10)
    	P0 &= ~(1 << 4);     // P0.4 set LOW(Buzzer Off)
    	
    	
    	
      #ifdef MCU_NRF24LE1
      while(hal_clk_get_16m_source() != HAL_CLK_XOSC16M)
      {
        // Wait until 16 MHz crystal oscillator is running
      }
      #endif
    
      #ifdef MCU_NRF24LU1P
      // Enable radio SPI
      RFCTL = 0x10U;
      #endif
    
    
      // Enable the radio clock
      RFCKEN = 1U;
    
      // Enable RF interrupt
      RF = 1U;
    
      // Enable global interrupt
      EA = 1U;
    
    	hal_nrf_set_output_power(HAL_NRF_0DBM);    	// output power 0DBM
    
    	hal_nrf_set_operation_mode(HAL_NRF_PTX);   		// Transmit mode
    	
    	hal_nrf_set_address_width(HAL_NRF_AW_5BYTES);  // Address width 5 bytes
    
    	hal_nrf_set_address(HAL_NRF_TX,TX_addr);     	// set TX address E1
    	hal_nrf_set_address(HAL_NRF_PIPE0,TX_addr);  	// set TX pipe0 E1 for Acknowledgement 
    
    	hal_nrf_write_reg(SETUP_RETR,0x01);            	// 1 max-retransmits
    
    	hal_nrf_set_rf_channel(2);                   	//channel 2
    	
    	hal_nrf_set_datarate(HAL_NRF_1MBPS);      		//data rate 1mbps
    	//hal_nrf_set_datarate(HAL_NRF_250KBPS);          // data rate 250kbps
    	
    	// Power up radio
      hal_nrf_set_power_mode(HAL_NRF_PWR_UP);
    	
      Fstate=1;
      radio_transmit = false;
    		
    	
    	TICKDV = 0x03;
    	WUIRQ = 1;  
    
      EA = 1U;
    	
    // cklf_rtc_init(0x00 , 0x3E80);  //RTC init 2 sec
     cklf_rtc_init(0x00 , 0x1F40);  //RTC init 1 sec
    // cklf_rtc_init(0x00 , 0x9C40);  //RTC init 5 sec
     //P0 |= (1 << 5);      // P0.4 set High
      for(;;)
      {
    		
       
    	hal_nrf_set_power_mode(HAL_NRF_PWR_UP);
    		
        // Write payload to radio TX FIFO
        hal_nrf_write_tx_payload(payload, 10U);
    	
    		
        // Toggle radio CE signal to start transmission
        CE_PULSE();
    
        radio_busy = true;
    				
        // Wait for radio operation to finish
        while (radio_busy)
    					{
    						
    					}
    				
    	 hal_nrf_set_power_mode(HAL_NRF_PWR_DOWN);		
    					
    		if(radio_transmit)
    		{
    			Checkout=0;
          radio_transmit = false;
    			 if(Fstate==1)        // Buzzer Loop 2 seconds
    			   {
    							for(Buzzer_loop=0;Buzzer_loop<10000;Buzzer_loop++)
    									{
    										delay_us(100);
    										P0 |= (1 << 4);      // P0.4 set High
    										delay_us(100);
    										P0 &= ~(1 << 4);     // P0.4 set LOW
    									}
    					Fstate++;	 
    				}
        }
    		
    		else
    		{
            Checkout++;
    			  //delay_ms(2);
    				if(Checkout >= 10)
    					{
    						Checkout=0;
    						Fstate=1;
    					}			
    		}
    		
    		WUF = 0;          //clear interupts
    		cpu_pwr_down();   //power MCU	
    
    
      }
    }
    
    // Radio interrupt
    NRF_ISR()
    {
      uint8_t irq_flags;
    
      // Read and clear IRQ flags from radio
      irq_flags = hal_nrf_get_clear_irq_flags();
    
      switch(irq_flags)
      {
    		 
    			// Transmission success
    			case (1 << (uint8_t)HAL_NRF_TX_DS):
    			radio_busy = false;
    			radio_transmit = true;
          // Data has been sent
          break;
    			// Transmission failed (maximum re-transmits)
    			case (1 << (uint8_t)HAL_NRF_MAX_RT):
          // When a MAX_RT interrupt occurs the TX payload will not be removed from the TX FIFO.
          // If the packet is to be discarded this must be done manually by flushing the TX FIFO.
          // Alternatively, CE_PULSE() can be called re-starting transmission of the payload.
          // (Will only be possible after the radio irq flags are cleared)
          // hal_uart_putstring("Data write failed: ");
    			hal_nrf_flush_tx();
          radio_busy = false;
          break;
    			default:
          break;
      }
    }
    
    // Wake up interupt
    WU_ISR()
    {
    
    }
    
  • @Pradeep: Next time please edit your question or add comment instead of using Answer section. I haven't seen you configure the RX_ADDR_P0 in the code. It should be configured. I suspect there could be a mismatch on the order of byte (byte endianness).

    You can try to test by using RX_ADDR_P1 = {0xE1, 0xE1, 0xE1, 0xE1, 0xE1}; RX_ADDR_P2 = 0xD2

    and then try both: TX_addr[5] = {0xE1,0xE1,0xE1,0xE1,0xD2}; and TX_addr[5] = {0xD2,0xE1,0xE1,0xE1,0xE1};

    respectively, to see if it's the case.

    I don't know how you write the register with nrf24_writeRegister() but I would suggest to use hal_nrf_write_multibyte_reg() function in hal_nrf.c . Or better could you use hal_nrf_set_address() as in the example ? I suggest to test first with both side from the code from the example to make sure it works before moving to your code.

  • Thanks for the reply. I will edit the question next time. Yes, we tried with TX_ADDR[5] = { 0xE1, 0xE1, 0xE1, 0xE1, 0xD2} and also with TX_ADDR[5] = {0xD2,0xE1,0xE1,0xE1,0xE1} on the Transmitter or Tag.

    The RX_ADDR_P2 is still not receiving data from the tag.

  • Have you tried: RX_ADDR_P1 = {0xE1, 0xE1, 0xE1, 0xE1, 0xE1}; ?

Related