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

nRF24LE1 deep sleep high current

Hi

i use nRF24LE1 in mode deep sleep it working but current consumption to high around 600 - 700 uA

please help

My code code

/**************************************** Copyright (c) ***** ***************************************************/





#include <reg24le1.h>
#include <stdint.h>
#include <stdbool.h>
#include "hal_nrf.h"
#include "hal_nrf_hw.h"
#include "hal_clk.h"
#include "hal_delay.h"
#include "hal_uart.h"

#define LED P13     // LED output
#define RSW P14     // Button wake up



#define TX_PAYLOAD_LEN 32  // wireless send data length
#define RF_CHANNEL 100     // channel
#define RX_PAYLOAD_LEN 32  // Receive data length

uint8_t TX_ADDRESS [5] = {'A', 'E', 'N', 'C', 'M'}; // TX address
uint8_t RX_ADDRESS [5] = {'A', 'E', 'N', 'C', 'S'}; // RX address

xdata bool radio_busy;
uint8_t RF_Recv_Flag;

xdata uint8_t tx_payload[32] = "Hello,W,B0,0000000000000,CCCC,O1";
xdata uint8_t rx_payload[32];

uint8_t RF_Recv_Flag;
uint16_t PipeAndLen;
long timeout = 0;

void IO_Init (void)
{
  P1DIR = 0x10;
  LED = 0;
  OPMCON = 0x00;
}

void RfCofig (void)
{
  RFCKEN = 1;                                                       // Enable RF clock
  hal_nrf_close_pipe(HAL_NRF_ALL);                                  // Turn off all channels first.
  hal_nrf_open_pipe(HAL_NRF_PIPE0,false);                           // Open channel 0 again.
  hal_nrf_set_operation_mode(HAL_NRF_PRX);                          // Mode: Receiver
  hal_nrf_set_rf_channel(RF_CHANNEL);                               // RF channel: 50. Receiving and sending must be on the same channel
  hal_nrf_set_datarate(HAL_NRF_250KBPS);                            // RF rate: 250KBPS
  hal_nrf_set_output_power(HAL_NRF_18DBM);                          // Power: 0DBM
  hal_nrf_set_crc_mode(HAL_NRF_CRC_8BIT);                           // Set CRC check: 16-bit CRC. Must be the same as the sending device
  hal_nrf_set_rx_payload_width(HAL_NRF_PIPE0, RX_PAYLOAD_LEN);      // Need to set the data length in receive mode



    hal_nrf_set_address(HAL_NRF_TX, TX_ADDRESS);
    hal_nrf_set_address(HAL_NRF_PIPE0, RX_ADDRESS);
    hal_nrf_set_power_mode(HAL_NRF_PWR_UP);                          //receiver powered on
    RF = 1;                                                          // enable wireless interrupts
    EA = 1;                                                          // Enable global interrupt
        
    CE_HIGH();                                                       // Enable reception
}



void RF_SendDat(void)
{
    CE_LOW();
    hal_nrf_set_operation_mode(HAL_NRF_PTX);                        //Pattern: Send
    hal_nrf_write_tx_payload(tx_payload,TX_PAYLOAD_LEN);
    CE_PULSE();                                                     //Transmit data wirelessly
    radio_busy = true;  
    while(radio_busy);                                              //Wait for the operation to finish
    hal_nrf_set_operation_mode(HAL_NRF_PRX);                        //Rx mode
    CE_HIGH();
}



void main()
 {

    IO_Init(); //IO initialization
    hal_clk_set_16m_source(HAL_CLK_XOSC16M);                        //Use an external 16MHz crystal
    OPMCON = 0x00;                                                  // Open latch

    while(1)
        {

            if(PWRDWN & 0x80) { PWRDWN = 0; }

            WUOPC1 = 0x10;                                          // Wake up on Pin P14
            if(P14 == 1)
            {
                LED = 1;
                tx_payload[23] = '1';
                RfCofig();
                RF_SendDat();
                hal_nrf_set_power_mode(HAL_NRF_PWR_DOWN);
                LED = 0;
                RFCKEN = 0;
                RF = 0;
                OPMCON = 0x06;
                PWRDWN = 0x01;
            }
        else 
           {
                LED = 1;
                tx_payload[23] = '0';
                RfCofig();
                RF_SendDat();
                hal_nrf_set_power_mode(HAL_NRF_PWR_DOWN);
                LED = 0;
                RFCKEN = 0;
                RF = 0;
                OPMCON = 0x02;
                PWRDWN = 0x01;
            }
        }
 }




//Description: Wireless interrupt service function


void rf_irq () interrupt INTERRUPT_RFIRQ
 {
    uint8_t irq_flags;
    irq_flags = hal_nrf_get_clear_irq_flags ();         // read and clear the wireless interrupt flag
    
    if (irq_flags & ((1 << HAL_NRF_TX_DS)))             // transimmter finish
      {
        radio_busy = false;
      }
    if (irq_flags & ((1 << HAL_NRF_MAX_RT)))            // re-transimmter
     {
        radio_busy = false;
        hal_nrf_flush_tx ();
     }


if (irq_flags & (1 << HAL_NRF_RX_DR))                   // Receive interrupt
    {
     while (! hal_nrf_rx_fifo_empty ())                 // Read data
       {
        PipeAndLen = hal_nrf_read_rx_payload (rx_payload);
       }
        hal_nrf_flush_rx ();
        RF_Recv_Flag = 1;                               // Receive valid flag is set
    }

 }

/******************************************** END FILE *** **************************************************/

Parents
  • Hi,

     

    Could you try disconnecting all inputs in your IO-init, then measure the current consumption?

    You could do something like this:

    void IO_Init(void)
    {
        uint8_t i;
        // Disconnect unused GPIOs to avoid them floating in sleep
        for (i = 0; i < 8; i++)
        {
            P0CON = 0x70 + i;
            P1CON = 0x70 + i;
            P2CON = 0x70 + i;
            P3CON = 0x70 + i;
        }    
        P1DIR = 0x10;
        // Set P1.4 as output again
        P1CON = 0x00 + 4;
        LED = 0;
        OPMCON = 0x00;
    }

    Cheers,

    Håkon

  • hi thank for your reply, now current consumption down to 400 - 500 nA

    but i can't wake up chip from P14

    please check my code

    #include <reg24le1.h>
    #include "hal_delay.h"
    
    #define LED  P14
    
    
    
    
    void IO_Init(void)
    {
        char i;
        // Disconnect unused GPIOs to avoid them floating in sleep
        for (i = 0; i < 8; i++)
        {
            P0CON = 0x70 + i;
            P1CON = 0x70 + i;
            P2CON = 0x70 + i;
            P3CON = 0x70 + i;
        } 
        P0DIR = 0xFF;	
        P1DIR = 0x10;           // P14 input , P13 output
    	P2DIR = 0xFF;
        P3DIR = 0xFF;
                        
        P1CON = 0x00 + 3;       // Set P1.2 as output 
    	P1CON = 0x70 + 4;       // Set P1.4 as input 
    
        LED = 0;
        OPMCON = 0x00;
        
    } 
    
    void main()
    { 
       IO_Init();
       while(1)
       {
         if(PWRDWN & 0x80) 
           {  
             PWRDWN = 0; 
           }
     	    
     	    WUOPC1 = 0x10;          // Interrupt wake up P1.4
     	    
     	    if(P14 == 1) 
     	      {
     	        LED = 1;
     	        delay_ms(100);
     	        LED = 0;
     	        OPMCON = 0x06;      // wake up pin when LOW
     	      }
     	    else
     	      {
     	        LED = 1;
     	        delay_ms(100);
     	        LED = 0;
     	        OPMCON = 0x02;      // wake up pin when HIGH
     	      }
     	      
     	    PWRDWN = 0x01;          // deep sleep
       
       
       }
    
    }

    thank 

  • On line 26: The PxCON for P14 should be P1CON = (0x10 + 4); to set it to input with no pull-resistor. If you do not have an external pull-resistor, one can be applied by setting bits 6:5 to 01 or 10 (see the datasheet for more info).

    It seems that you are setting the output "LED" and the wakeup pin both to the same GPIO, P14. Could you try setting the LED back to P13?

    Cheers,

    Håkon

  • it work now thank you 

    current consumption around 200 nA 

Reply Children
No Data
Related