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

NRF24LE1 Communication

Hi all! I am approaching this with pretty much zero experience but what I'm trying to build should be a piece of cake for you so any help, example code, advice will be appreciated.

The idea is to build a simple notification system. The RX is connected to a 3V coin cell through an on/off switch and couple LED's. If switched on, LED blinks once and the RX enters deep sleep mode and wakes up when a signal from a TX is received. When RX wakes up, LED's blink until RX is switched off. If switched off/on, RX resets, enters deep sleep and waits for a signal.

The TX is connected to a 3V power source. As soon as TX switches on, it sends a signal to RX and RX wakes up. The TX repeatedly sends signal to RX for 2 minutes and enters deep sleep if not switched off.

I'm using 2 x NRF24LE1, Q32, Keil software, mpro burner. I have programmed a device to blink a LED (Hello World) and 2 devices to communicate with "enhanced_shockburst" example, but that is as far is I've got. Trying to add deep sleep and wake up on pins resulted in nearly burning the chips.

Maybe someone has done/made something similar and can help even a bit?

Send help to NRF24LE1 street. Thank you in advance!

  • In connection with the TX module setup, the RX module would be programmed in RTC mode and ESB_prx. When going through the question section I saw a post where you uploaded an example where you modified the ESB TX example to use RTC sleep. I see the difference between the orig. ESB TX example. The problem is that I don't really understand how the WUOPC0/1 works with the RTC sleep. In the example codes for RTC I see that there is "wakeup_tick". Does that part of the code needs to be changed to WUOPC0/1 or the "wakeup_tick" remains and WUOPC0/1 is added? Thank you for you patience with me. Many thanks, M

  • Hi
    These are independent mechanisms and can be enabled separately. There are separate interrupt handlers for the two wakeup sources that will fire, depending on what woke you up.
    In other words you shouldn't have to change any of the existing code to add the wakeup on pin functionality.
    Best regards

  • Hello! :) So I've been experimenting with the Nordic's given example codes and codes I could find on the internet. From 0 knowledge in this I have went to at least some knowledge in all this. I have been trying to merge the ESB(PRX) example code and the "Register retention, timers on" and WUOP funstion examples, but it does not seem to working. When I switch on the PRX, LED's just light up and there is no reaction when I put pins to GND on PRX and PTX modules. The setup is PRX connected to 3.3V, GND and P04, P05 to LED's. On the PTX side, 3.3V, GND and P04, P05 to buttons. I will attach the code I've been trying to get working. I would greatly appreciate if you could take a look and see what might be the problem. Thank you for any tips and suggestions!

  • // Global variables uint8_t payload[3];

    void main()
    {
    	// Open GPIO latches in case they were previously locked.
      
    OPMCON = 0x00;
    	
    #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 = 0x10;
      #endif
    
    	P0CON = 0x70; // Disable digital input buffer, pin used for 32kHz.
    	P0CON = 0x71; // Disable digital input buffer, pin used for 32kHz.
      //P0CON = 0x76;    // P06 must not be disconnected as it is required to wake up the nRF24LE1 
    
      // Set P0.6 as input for wake up, others as output
      
    P0DIR = 0x40;
    
      // Enable the radio clock
      RFCKEN = 1; 
    
    	hal_rtc_start(false);
    	hal_clklf_set_source(HAL_CLKLF_XOSC32K); 
    	hal_rtc_set_compare_mode(HAL_RTC_COMPARE_MODE_0);
    	hal_rtc_set_compare_value(0x7FFF);
    	hal_rtc_start(true);
    
    	// Wait for the 32kHz to startup (change phase)
    	while((CLKLFCTRL&0x80)==0x80);
    	while((CLKLFCTRL&0x80)!=0x80);
    	
      // Enable RF interrupt
      RF = 1;
      
    // Enable global interrupt
      EA = 1;
    	
    IEN1 = 0x08;
    
      // Configure radio as primary receiver (PRX)
      hal_nrf_set_operation_mode(HAL_NRF_PRX);
    
      // Set payload width to 3 bytes
      hal_nrf_set_rx_payload_width((int)HAL_NRF_PIPE0, 3);
    
      // Power up radio
      hal_nrf_set_power_mode(HAL_NRF_PWR_UP);
    
      // Enable receiver
      CE_HIGH();
    
      for(;;)
    	
    {
    		// Wake up on pin P0.6
    		
    WUOPC0 = 0x40;
    		// Inverse wakeup on pin polarity on selected GPIO's (P06 on 24-pin LE1. P06, P12 and P14 on 32-pin LE1. P22 and P26 on 48-pin LE1).
        
    OPMCON |= 0x04;
    		
    // Lock GPIO latches. 
        
    OPMCON |= 0x02;
    		
    // Register retention mode
    		
    PWRDWN = 0x04;
    		
    // Standby mode (wait for interrupt)
    		
    PWRDWN = 0x07;
    		
    // Clear PWRDWN
    		
    PWRDWN = 0x00;
    		
    // Continue to run code
    		
    P03 = !P03; 
    	};
    }
    
    void wakeup_tick() interrupt INTERRUPT_TICK
    {
    P02 = !P02;
    }
    
    // Radio interrupt
    NRF_ISR()
    {
      uint8_t irq_flags;
    
      // Read and clear IRQ flags from radio
      irq_flags = hal_nrf_get_clear_irq_flags();
    
      // If data received
      if((irq_flags & (1<<(uint8_t)HAL_NRF_RX_DR)) > 0)
      {
        
    // Read payload
        while(!hal_nrf_rx_fifo_empty())
        {
          hal_nrf_read_rx_payload(payload);
        }
    
        
    // Write received payload[0] to port 0
        P0 = payload[0];
      }
    }
    
    /** @} */
    
  • Hello! It's been a while but slow and steady I have almost produced the system I need. 

    But I have encountered a problem I can't overcome. My simple system works just fine as long as I have on pair of nrf24le1's as they use the default address. Problem is, I need several pairs working in close range, therefore I want to set address for each pair of nrf's I need.

    When I use the lines: hal_nrf_set_address(HAL_NRF_TX, tx_address) and hal_nrf_set_address(HAL_NRF_PIPE0, rx_address); in my code, Keil compiler shows: "warning C196: mspace probably invalid" when compiling

    What am I doing wrong? Any suggestions?

Related