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

nRF52833 development

Hello all,

I am working on low power sensor development with nRF52833 as target. I have some questions but I'm not sure it this was addressed in some other posts.

1. I don't have nRF52833 DK but instead I use nRF52840DK for development under SES environment. What in particular should I be aware of when generating target code for nRF52833?

2. I wan't to place sensor in sleep state for longer period of time. From product spec I understand that I should use wake on RTC and no RAM retention for lowest possible power. Because of no RAM retention, I need CPU to restart after timeout, not to go to application timer timeout handler but to top of main. How can I set this up?

Thanks

Parents
  • Hi

    No problem at all, we're here to help you get a better understanding of nRF development. I should have been clearer in my explanation.

    The RTC peripheral is its own independent peripheral and is not dependent on the app_timer in order to trigger a wake-up, as long as the peripheral is powered you won't be dependent on what the RAM is doing. You can take a look at the RTC peripheral example to see how you can use RTC without the app_timer.

    Keep in mind that, depending on your application, you might not see a better average current consumption if you have to reinitialize a bunch of peripherals whenever your device wakes up due to the RAM not being retained, so it might be just as energy-efficient to have RAM retention if you save a lot of power on the wake-up process that way.

    Best regards,

    Simon

  • Hi Simon,

    My application is such that sensor sleeps for 8 hours, wakes up, performs soft reset, then starts advertising for few minutes, then goes back to 8 hour sleep. It stays in this loop forever. As you can see, battery life greatly depends on power during sleep. I hope to achieve 1.5uA sleep current as specified in product spec (wake on RTC event and no RAM retention)

    ION_RAMOFF_RTC

    System ON, no RAM retention, wake on RTC (running from LFRC clock)

    1.50

    µA

    Actually, RAM retention is term applicable only for System OFF state (above table entry may be misleading because wake on RTC event assumes system is ON). I think the table entry should say "System ON, all RAM powered off, wake on RTC". 

    I have modified RTC example as below. After RTC timer is initialised, all of the RAM is powered off. When RTC interrupts, soft reset is called.

    This is exactly what I want to do in my application. Result is that my nRF52840 DK bricks itself (I need to recover it by (nrfjprog --recover --family NRF52)

    I actually expected this will happen because turning ALL of the RAM off is like "cutting the branch you sit on" Slight smile

    Can you illustrate example which results in 1.5uA current during timeout and wake on RTC?

    /**
     * Copyright (c) 2014 - 2020, 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.
     *
     */
    /** @file
     * @defgroup rtc_example_main main.c
     * @{
     * @ingroup rtc_example
     * @brief Real Time Counter Example Application main file.
     *
     * This file contains the source code for a sample application using the Real Time Counter (RTC).
     *
     */
    
    #include "nrf.h"
    #include "nrf_gpio.h"
    #include "nrf_drv_rtc.h"
    #include "nrf_drv_clock.h"
    #include "boards.h"
    #include "app_error.h"
    #include 
    #include 
    
    #define COMPARE_COUNTERTIME  (3UL)                                        /**< Get Compare event COMPARE_TIME seconds after the counter starts from 0. */
    
    #ifdef BSP_LED_0
        #define TICK_EVENT_OUTPUT     BSP_LED_0                                 /**< Pin number for indicating tick event. */
    #endif
    #ifndef TICK_EVENT_OUTPUT
        #error "Please indicate output pin"
    #endif
    #ifdef BSP_LED_1
        #define COMPARE_EVENT_OUTPUT   BSP_LED_1                                /**< Pin number for indicating compare event. */
    #endif
    #ifndef COMPARE_EVENT_OUTPUT
        #error "Please indicate output pin"
    #endif
    
    const nrf_drv_rtc_t rtc = NRF_DRV_RTC_INSTANCE(0); /**< Declaring an instance of nrf_drv_rtc for RTC0. */
    
    /** @brief: Function for handling the RTC0 interrupts.
     * Triggered on TICK and COMPARE0 match.
     */
    static void rtc_handler(nrf_drv_rtc_int_type_t int_type)
    {
        NVIC_SystemReset();
    
    
    }
    
    /** @brief Function configuring gpio for pin toggling.
     */
    static void leds_config(void)
    {
        bsp_board_init(BSP_INIT_LEDS);
    }
    
    /** @brief Function starting the internal LFCLK XTAL oscillator.
     */
    static void lfclk_config(void)
    {
        ret_code_t err_code = nrf_drv_clock_init();
        APP_ERROR_CHECK(err_code);
    
        nrf_drv_clock_lfclk_request(NULL);
    }
    
    /** @brief Function initialization and configuration of RTC driver instance.
     */
    static void rtc_config(void)
    {
        uint32_t err_code;

    //Initialize RTC instance nrf_drv_rtc_config_t config = NRF_DRV_RTC_DEFAULT_CONFIG; config.prescaler = 4095; err_code = nrf_drv_rtc_init(&rtc, &config, rtc_handler); APP_ERROR_CHECK(err_code); //Enable tick event & interrupt nrf_drv_rtc_tick_enable(&rtc,true); //Set compare channel to trigger interrupt after COMPARE_COUNTERTIME seconds err_code = nrf_drv_rtc_cc_set(&rtc,0,COMPARE_COUNTERTIME * 8,true); APP_ERROR_CHECK(err_code); //Power on RTC instance nrf_drv_rtc_enable(&rtc); } /** * @brief Function for application main entry. */ int main(void) { leds_config(); lfclk_config(); rtc_config(); NRF_POWER->RAM[0].POWERCLR = 0x3; NRF_POWER->RAM[1].POWERCLR = 0x3; NRF_POWER->RAM[2].POWERCLR = 0x3; NRF_POWER->RAM[3].POWERCLR = 0x3; NRF_POWER->RAM[4].POWERCLR = 0x3; NRF_POWER->RAM[5].POWERCLR = 0x3; NRF_POWER->RAM[6].POWERCLR = 0x3; NRF_POWER->RAM[7].POWERCLR = 0x3; NRF_POWER->RAM[8].POWERCLR = 0x3F; while (true) { __SEV(); __WFE(); __WFE(); } } /** @} */



    But if I only power OFF RAM 8, like this

    NRF_POWER->RAM[8].POWERCLR = 0x3F;

    Then it doesn't brick itself.

    What I meant is that some RAM must stay powered on during sleep.

    Regards

    Kerim



  • Hi again,

    I figured out that if I change this line

    err_code = nrf_drv_rtc_init(&rtc, &config, rtc_handler);

    to this:

    err_code = nrf_drv_rtc_init(&rtc, &config, 0);

    then it seems to work fine, no bricking when all RAM power is off. Presumably replacing RTC callback routine by system reset vector. I guess 0 is system reset vector, is it?

    Regards

Reply Children
No Data
Related