[nrf51][nrf52][low power] How to enter low power consumption when using RTX

Publisher:ZenMaster123Latest update time:2022-09-15 Source: csdnKeywords:nrf51  nrf52  low  power  RTX Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

1. Because RTX uses the RTC1 interrupt, it wakes up frequently and cannot enter the sleep state.

2. Idea: Before entering low power consumption, turn off the power of RTC1, and reconfigure RTC1 after waking up with a button.


pseudocode:

Before entering low power consumption


1. Turn off peripheral GPIO

        nrf_gpio_cfg_default(N);


2. Close the serial port

        NRF_UART0->ENABLE = 0;

        NRF_UART0->POWER = 0;

        app_uart_close();

3. Disable RTC1 interrupt

        __disable_irq();

        NVIC_DisableIRQ(RTC1_IRQn);

        NRF_RTC1->POWER = 0; //Stop RTC

        __enable_irq();

4. Set key interrupt

        KEY_IRQn_INIT();

        /*

        Content Examples

        NRF_GPIO->PIN_CNF[Config_Key1_PORT_PIN] |= (GPIO_PIN_CNF_SENSE_Low << GPIO_PIN_CNF_SENSE_Pos);

        NRF_GPIOTE->INTENSET = GPIOTE_INTENSET_PORT_Msk; //Enable interrupt

        NVIC_SetPriority(GPIOTE_IRQn, 1); //Set the interrupt priority to 1

        NVIC_EnableIRQ(GPIOTE_IRQn); //Enable general interrupt

        */

5. Go to sleep

        sd_app_evt_wait();


Key interrupt function:


void GPIOTE_IRQHandler(void) //GPIOTE interrupt service function

{

    unsigned int expected_time;

    if (NRF_GPIOTE->EVENTS_PORT != 0)

    {

        NRF_GPIOTE->EVENTS_PORT = 0; //Interrupt clear

        if (NRF_RTC1->POWER == 0)

        {

            NVIC_EnableIRQ(RTC1_IRQn);

            NRF_RTC1->POWER = 1; //Start RTC

            NRF_RTC1->EVENTS_TICK = 1; //Start counting

            NRF_RTC1->TASKS_START = 1; //Start counting

            NRF_RTC1->PRESCALER = 0x20; //Set clock reference 32768 0x20==32

        }

        if (nrf_gpio_pin_read(Config_Key5_PORT_PIN) == 0) //Check whether it is woken up by this button

        {

            

        }

    }

}


Keywords:nrf51  nrf52  low  power  RTX Reference address:[nrf51][nrf52][low power] How to enter low power consumption when using RTX

Previous article:[nrf52832] [s332] Building a development environment and precautions
Next article:[nrf51][nrf52][MCU] ble bluetooth unlimited broadcast continuous broadcast

Latest Microcontroller Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号