Hi
i use nRF24LE1 in mode deep sleep it working but current consumption to high around 600 - 700 uA
please help
My code code
Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**************************************** 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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/**************************************** 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 *** **************************************************/