Hi all
How to put BL654 in deep sleep mode and standby doze mode using nordic nrf52840 ?? Also how to turn the system off??
Thanks
Hi all
How to put BL654 in deep sleep mode and standby doze mode using nordic nrf52840 ?? Also how to turn the system off??
Thanks
Hi
Depending on whether you're using the SoftDevice or not, there are a few ways to do this.
No SoftDevice:
SoftDevice enabled:
Best regards,
Simon
Hi thanks
The soft device is enabled. I'm trying to use sd_app_evt_wait(); but the current consumption is 1.7 mA which is too high for sleep/doze mode. What could be the reason for this? I have not configured any gpio and i am using following code.
main()
{
while(1)
{
sd_app_evt_wait();
}
}
These are some of the module enabled in sdk
BLE DB DISCOVERY ENABLED
NRF BLE GATT ENABLED
NRF BLE QWR ENABLED
NRF BLE SCAN ENABLED
PM CENTRAL ENABLED
PM SERVICE CHANGE ENABLED
PM PEER RANKS ENABLED
NRF CRYPTO ENABLED
GPIOTE ENABLED
NRFX CLOCK ENABLED
NRFX GPIOTE ENABLED
NRFX PRS ENABLED
NRFX PWM ENABLED
NRFX PWM0 ENABLED
NRFX PWM1 ENABLED
NRFX RTC ENABLED
NRFX SPIM ENABLED
NRFX SPI ENABLED
NRFX SPI0 ENABLED
NRFX SPI1 ENABLED
NRFX TIMER ENABLED
NRFX TWI ENABLED
NRFX TWI0 ENABLED
NRFX UARTE ENABLED
NRFX CLOCK ENABLED
NRFX PPI ENABLED
NRFX PWM ENABLED
PWM0 ENABLED
RTC ENABLED
RTC2 ENABLED
SPI ENABLED
SPI1 ENABLED
SPI USE EASY DMA
SPI2 ENABLED
TIMER ENABLED
TIMER0 ENABLED
TIMER1 ENABLED
TWI ENABLED
TWI0 ENABLED
TWI0 USE EASY DMA
UART ENABLED
UART0 ENABLED
APP PWM ENABLED
APP SCHEDULER ENABLED
APP TIMER ENABLED
Can you please upload your main.c file, so I can take a look at what's enabled and not in your application? Also, could you explain how you're measuring the current of your board? Please check out the current consumption guide for all the trivial things to look out for when trying to reduce the current consumption.
Best regards,
Simon
Hi
I have connected a 1 ohm resistor setup across the battery to measure the current consumption.
The board is not going to sleep/doze mode for some reason. My doubt is that the SPI peripheral is active which is preventing the board from going into the sleep mode. I have seen the chip select (slave select) low on oscilloscope. It looks to me that the spi driver are controlling the ss pin and even though I'm making it high in FW, it is still low. I have started another thread about the chip select https://devzone.nordicsemi.com/f/nordic-q-a/53866/slave-select-pin-always-low
main.c
** * Copyright (c) 2016 - 2018, Nordic Semiconductor ASA * * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * 1. Redistributions of source code must retain the above copyright notice, this * list of conditions and the following disclaimer. * * 2. Redistributions in binary form, except as embedded into a Nordic * Semiconductor ASA integrated circuit in a product or a software update for * such product, must reproduce the above copyright notice, this list of * conditions and the following disclaimer in the documentation and/or other * materials provided with the distribution. * * 3. Neither the name of Nordic Semiconductor ASA nor the names of its * contributors may be used to endorse or promote products derived from this * software without specific prior written permission. * * 4. This software, with or without modification, must only be used with a * Nordic Semiconductor ASA integrated circuit. * * 5. Any software provided in binary form under this license must not be reverse * engineered, decompiled, modified and/or disassembled. * * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ /**@cond To Make Doxygen skip documentation generation for this file. * @{ */ /********************************************************************* * INCLUDES */ #include <stdbool.h> #include <stdint.h> #include <stdio.h> #include <string.h> #include "amt.h" #include "counter.h" #include "app_error.h" #include "app_timer.h" #include "ble.h" #include "ble_advdata.h" #include "ble_gatt.h" #include "ble_hci.h" #include "ble_srv_common.h" #include "bsp_btn_ble.h" #include "nordic_common.h" #include "nrf.h" #include "nrf_ble_gatt.h" #include "nrf_ble_qwr.h" #include "nrf_ble_scan.h" #include "nrf_cli.h" #include "nrf_cli_rtt.h" #include "nrf_cli_uart.h" #include "nrf_gpio.h" #include "nrf_pwr_mgmt.h" #include "nrf_sdh.h" #include "nrf_sdh_ble.h" #include "sdk_config.h" #include "nrf_log.h" #include "nrf_log_ctrl.h" #include "nrf_log_default_backends.h" #include "app_util_platform.h" #include "nrf_delay.h" #include "nrf_drv_spi.h" #include "nrf_drv_twi.h" #include "app_pwm.h" #include "nrf_drv_saadc.h" #define SPI_INSTANCE_0 2 /**< SPI instance index. */ #define SPI_INSTANCE_1 1 /**< SPI instance index. */ #define TWI_INSTANCE_ID 0 #define BLE_TIMER_INTERVAL APP_TIMER_TICKS(8) #define DATA_LENGTH_DEFAULT 27 /**< The stack default data length. */ #define DATA_LENGTH_MAX 251 /**< The stack maximum data length. */ #define CONN_INTERVAL_DEFAULT (uint16_t)(MSEC_TO_UNITS(7.5, UNIT_1_25_MS)) /**< Default connection interval used at connection establishment by central side. */ #define CONN_INTERVAL_MIN (uint16_t)(MSEC_TO_UNITS(10, UNIT_1_25_MS)) /**< Minimum acceptable connection interval, in units of 1.25 ms. */ #define CONN_INTERVAL_MAX (uint16_t)(MSEC_TO_UNITS(15, UNIT_1_25_MS)) /**< Maximum acceptable connection interval, in units of 1.25 ms. */ #define CONN_SUP_TIMEOUT (uint16_t)(MSEC_TO_UNITS(100, UNIT_10_MS)) /**< Connection supervisory timeout (4 seconds). */ #define SLAVE_LATENCY 0 /**< Slave latency. */ #define SCAN_ADV_LED BSP_BOARD_LED_0 #define READY_LED BSP_BOARD_LED_1 #define PROGRESS_LED BSP_BOARD_LED_2 #define DONE_LED BSP_BOARD_LED_3 #define BOARD_TESTER_BUTTON BSP_BUTTON_2 /**< Button to press at the beginning of the test to indicate that this board is connected to the PC and takes input from it via the UART. */ #define BOARD_DUMMY_BUTTON BSP_BUTTON_3 /**< Button to press at the beginning of the test to indicate that this board is standalone (automatic behavior). */ #define BUTTON_DETECTION_DELAY APP_TIMER_TICKS(50) /**< Delay from a GPIOTE event until a button is reported as pushed (in number of timer ticks). */ #define APP_BLE_CONN_CFG_TAG 1 /**< Tag that refers to the BLE stack configuration. */ #define APP_BLE_OBSERVER_PRIO 3 /**< BLE observer priority of the application. There is no need to modify this value. */ static const nrf_drv_spi_t spi_0 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE_0); /**< SPI instance */ static const nrf_drv_spi_t spi_1 = NRF_DRV_SPI_INSTANCE(SPI_INSTANCE_1); /**< SPI instance */ /* TWI instance. */ static const nrf_drv_twi_t m_twi = NRF_DRV_TWI_INSTANCE(TWI_INSTANCE_ID); APP_PWM_INSTANCE(PWM1,1); // Create the instance "PWM1" using TIMER1. static uint8_t m_adv_handle = BLE_GAP_ADV_SET_HANDLE_NOT_SET; /**< Advertising handle used to identify an advertising set. */ static uint8_t m_enc_advdata[BLE_GAP_ADV_SET_DATA_SIZE_MAX]; /**< Buffer for storing an encoded advertising set. */ APP_TIMER_DEF(m_timer_id); APP_TIMER_DEF(m_timer_id2); NRF_BLE_GATT_DEF(m_gatt); /**< GATT module instance. */ NRF_BLE_QWR_DEF(m_qwr); /**< Context for the Queued Write module.*/ BLE_DB_DISCOVERY_DEF(m_ble_db_discovery); /**< Database discovery module instance. */ NRF_BLE_SCAN_DEF(m_scan); /**< Scanning Module instance. */ nrf_ble_amtc_t m_amtc; nrf_ble_amts_t m_amts; NRF_SDH_BLE_OBSERVER(m_amtc_ble_obs, BLE_AMTC_BLE_OBSERVER_PRIO, nrf_ble_amtc_on_ble_evt, &m_amtc); NRF_SDH_BLE_OBSERVER(m_amts_ble_obs, BLE_AMTS_BLE_OBSERVER_PRIO, nrf_ble_amts_on_ble_evt, &m_amts); NRF_CLI_UART_DEF(cli_uart, 0, 64, 16); NRF_CLI_RTT_DEF(cli_rtt); NRF_CLI_DEF(m_cli_uart, "throughput example:~$ ", &cli_uart.transport, '\r', 4); NRF_CLI_DEF(m_cli_rtt, "throughput example:~$ ", &cli_rtt.transport, '\n', 4); void main(void) { nrf_pwr_mgmt_init(); app_timer_init(); counter_init(); //config.prescaler =32 peripheral_init(); // Inside peripheral_init() // spi_open(SPI0, NRF_SPI_FREQ_8M, NRF_DRV_SPI_MODE_0); // spi_open(SPI1, NRF_SPI_FREQ_250K, NRF_DRV_SPI_MODE_3); //SD card frequency range 100-400 KHz while initializing // twi_init(m_twi); // nrf_gpio_cfg_output(SDCARD_CS); // nrf_gpio_pin_set(SDCARD_CS); // nrf_gpio_cfg_output(SDCARD_CS1); // nrf_gpio_pin_set(SDCARD_CS1); // nrf_gpio_cfg_output(TWI_CLK); // SetPin(TWI_CLK,HIGH); // nrf_gpio_cfg_output(TWI_DATA); // SetPin(TWI_DATA,HIGH); application_timers_start(); //starting both timers here nrf_sdh_enable_request(); nrf_sdh_ble_default_cfg_set(APP_BLE_CONN_CFG_TAG, &ram_start); nrf_sdh_ble_enable(&ram_start); NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL); while(1) { ret_code_t ret_code = sd_app_evt_wait(); ASSERT((ret_code == NRF_SUCCESS) || (ret_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)); UNUSED_VARIABLE(ret_code); } }
Hi
Do you have the idle_state_handle() function in your application? I suggest you use this function instead, as it prepares the chip to go to sleep instead of just putting it to sleep. The idle_state_handle will check if the logger module is done with all its processing before calling the nrf_pwr_mgmt which prepares the chip for sleep and sets wake up pins, etc. before calling the sd_app_evt_wait() function. Please see I.E. the ble_app_uart example to see how it is called.
Best regards,
Simon