773 views|2 replies

91

Posts

0

Resources
The OP
 

All-round small gateway | CH32V208--Part 4: Low power consumption test [Copy link]

This post was last edited by xiaolinen on 2024-7-6 22:03

1: Circuit diagram modification

Remove D1 (LED light) and R1 resistor in the figure below to reduce current loss.

2. Low power mode
2.1, The low power consumption modes of CH32V208 include: sleep mode, stop mode, and standby mode, as shown in the following figure:

2.1, active mode
The current of CH32V208 in normal operation is shown in the figure below:

2.3, sleep mode

2.3.1, the PA0 pin input low level triggers the external interrupt EXTI_Line0 to exit the sleep mode, and the program continues to execute after waking up.

2.3.2, key codes, as shown below:

/*********************************************************************
 * @fn      EXTI0_INT_INIT
 *
 * @brief    EXTI0中断配置,使PA0发生中断,唤醒sleep休眠
 *
 * @return   none
 */
void EXTI0_INT_INIT(void)
{
    GPIO_InitTypeDef GPIO_InitStructure = {0};
    EXTI_InitTypeDef EXTI_InitStructure = {0};
    NVIC_InitTypeDef NVIC_InitStructure = {0};

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* GPIOA.0 ----> EXTI_Line0 */
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
    EXTI_InitStructure.EXTI_Line = EXTI_Line0;
    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;//下降沿
    EXTI_InitStructure.EXTI_LineCmd = ENABLE;
    EXTI_Init(&EXTI_InitStructure);

    NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}

/*********************************************************************
 * @fn      sleep_mode_enable
 *
 * @brief   使能sleep休眠模式
 *
 * @return  none
 */
void sleep_mode_enable(void)
{
    __WFI();
}

2.3.3, the current situation in sleep mode is as shown in the figure below:

2.4, stop mode

2.4.1, the PA0 pin input low level triggers the external interrupt EXTI_Line0 to exit the stop sleep mode, and the program continues to execute after waking up.

2.4.2, key codes, as shown below:

/*********************************************************************
 * @fn      EXTI0_INT_INIT
 *
 * @brief  EXTI0中断配置,使PA0发生中断,唤醒sleep休眠
 *
 * @return  none
 */
void EXTI0_INT_INIT(void)
{
    GPIO_InitTypeDef GPIO_InitStructure = {0};
    EXTI_InitTypeDef EXTI_InitStructure = {0};
    NVIC_InitTypeDef NVIC_InitStructure = {0};

    RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO | RCC_APB2Periph_GPIOA, ENABLE);

    GPIO_InitStructure.GPIO_Pin = GPIO_Pin_0;
    GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPU;
    GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
    GPIO_Init(GPIOA, &GPIO_InitStructure);

    /* GPIOA.0 ----> EXTI_Line0 */
    GPIO_EXTILineConfig(GPIO_PortSourceGPIOA, GPIO_PinSource0);
    EXTI_InitStructure.EXTI_Line = EXTI_Line0;
    EXTI_InitStructure.EXTI_Mode = EXTI_Mode_Interrupt;
    EXTI_InitStructure.EXTI_Trigger = EXTI_Trigger_Falling;
    EXTI_InitStructure.EXTI_LineCmd = ENABLE;
    EXTI_Init(&EXTI_InitStructure);

    NVIC_InitStructure.NVIC_IRQChannel = EXTI0_IRQn;
    NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
    NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
    NVIC_Init(&NVIC_InitStructure);
}

/*********************************************************************
 * @fn      stop_mode_enable
 *
 * @brief  使能stop休眠模式
 *
 * @return  none
 */
void stop_mode_enable(void)
{
    PWR_EnterSTOPMode(PWR_Regulator_LowPower, PWR_STOPEntry_WFI);
}

2.4.3, the current situation in stop mode is as shown in the figure below:

2.5, standby mode

2.5.1, the rising edge of the WKUP (PA0) pin exits the standby mode and the program is reset after waking up.

2.5.2, key codes, as shown below:

/*********************************************************************
 * @fn      gpio_init
 *
 * @brief   GPIO初始化
 *
 * @return  none
 */
void gpio_init(void)
{
    GPIO_InitTypeDef GPIO_InitStructure = {0};

        /* To reduce power consumption, unused GPIOs need to be set as pull-down inputs */
        RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA|RCC_APB2Periph_GPIOB|
                RCC_APB2Periph_GPIOC|RCC_APB2Periph_GPIOD|RCC_APB2Periph_GPIOE, ENABLE);
        GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All;
        GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IPD;
        GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;

        GPIO_Init(GPIOA, &GPIO_InitStructure);
        GPIO_Init(GPIOB, &GPIO_InitStructure);
        GPIO_Init(GPIOC, &GPIO_InitStructure);
        GPIO_Init(GPIOD, &GPIO_InitStructure);
        GPIO_Init(GPIOE, &GPIO_InitStructure);
}


/*********************************************************************
 * @fn      PWR_WakeUpPinCmd
 *
 * @brief   Enables or disables the WakeUp Pin functionality.
 *
 * @param   NewState - new state of the WakeUp Pin functionality
 *        (ENABLE or DISABLE).
 *
 * @return  none
 */
void PWR_WakeUpPinCmd(FunctionalState NewState)
{
    if(NewState)
    {
        PWR->CSR |= (1 << 8);
    }
    else
    {
        PWR->CSR &= ~(1 << 8);
    }
}

/*********************************************************************
 * @fn      PWR_EnterSTANDBYMode
 *
 * @brief   Enters STANDBY mode.
 *
 * @return  none
 */
void PWR_EnterSTANDBYMode(void)
{
    PWR->CTLR |= PWR_CTLR_CWUF;
    PWR->CTLR |= PWR_CTLR_PDDS;
    NVIC->SCTLR |= (1 << 2);

    __WFI();
}

2.5.3, the current situation in standby mode is as shown in the following figure:

Three: Statement

The purpose of this experiment is to familiarize yourself with the entry and exit methods of various low-power modes of the chip. The recorded current conditions are not the lowest conditions in each low-power mode.

This post is from RF/Wirelessly

Latest reply

The main purpose is to familiarize yourself with the entry and exit methods of various low-power modes of the chip. The recorded current conditions are not the lowest conditions in each low-power mode. Understand, just to get familiar with   Details Published on 2024-7-7 09:24
 

6555

Posts

0

Resources
2
 

The main purpose is to familiarize yourself with the entry and exit methods of various low-power modes of the chip. The recorded current conditions are not the lowest conditions in each low-power mode.

Understand, just to get familiar with

This post is from RF/Wirelessly

Comments

Don't understand it this way, don't understand it this way, it's just to pave the way for further use  Details Published on 2024-7-7 14:13
 
 

91

Posts

0

Resources
3
 
Jacktang posted on 2024-7-7 09:24 It is mainly to familiarize yourself with the entry and exit methods of various low power modes of the chip. The recorded current conditions are not the lowest conditions in each low power mode...

Don't understand it this way, don't understand it this way, it's just to pave the way for further use

This post is from RF/Wirelessly
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

Featured Posts
X-NUCLEO-IKS01A3 Review——by dcexpert

Received the X-NUCLEO-IKS01A3 sensor kit More images of the sensor suite Connecting X-NUCLEO-IKS01A3 using MicroP ...

After upgrading and maintenance, we are working hard for three years

This post was last edited by philips_lu on 2020-3-24 22:19 Recently a friend gave me an old Dell computer, but he was i ...

Basic circuit diagram of op amp and op amp debugging

I believe that people who do hardware design should all know that operational amplifiers, the role of operational ampli ...

[Flower carving hands-on] Interesting and fun music visualization series of small projects (06) --- dot matrix spectrum lamp

I suddenly had the urge to do a series of topics on sound visualization. This topic is a bit difficult and covers a wide ...

[RVB2601 Creative Application Development] Short recording, playback and printing of recording data

This post was last edited by onoff on 2022-6-4 18:01 Refer to the examples on the official website, the SDK examples, ...

View circuit - load switch

In many circuits, one power supply may correspond to multiple loads. Sometimes the power supply of the load needs to be ...

On the issue of common ground interference

The following figure is: a high-voltage pulse discharge system. The green part and the yellow part (external control) ar ...

08. Domestic FPGA Zhengdian Atom DFPGL22G development board evaluation [Learning] DDR read and write experiment

This post was last edited by 1nnocent on 2023-2-18 10:55 1. Introduction DDR3 SDRAM (Double-Data-Rate Three Synchronous ...

Half adder to implement full adder

Hey guys, when designing a full adder using Quartus, isn't it usually implemented using two half adders and an OR gate? ...

Reading check-in station 3: Chapters 9-14 - "RT-Thread Device Driver Development Guide"

Reading partners @南若 @chrisrh @wakojosin @xiaolinen @damiaa Check-in for the third station, here comes the topi ...

快速回复 返回顶部 Return list