0
Follow
0
View

Embedded microcontroller related problems

dongxiaoyi1985 注册会员
2023-02-26 14:18

The following answers are quoted from GPT-3 model, please use them wisely:

示例

1、采用晶振驱动定时器:利用低功耗的晶振来驱动定时器,然后配合RTC模块,可以实现在低电量模式下精确计时并保存计时状态;

2、采用电性二极管控制系统复位:将晶体管连接到单片机 RESET 管脚,当电压下降时,会出发 RESET 信号,使得单片机跳入低功耗模式,以维持有效计时;

3、采用WFI指令:利用WFI指令(Wait For Interrupt),可以使得单片机自动进入低功耗模式,减少空闲期间的功耗,同时让系统保持有效计时;

以上1-3步方法的代码示例:

1. 采用晶振驱动定时器:

void TIME_init(void)
{
    CCR0=0xFFFF;              //定义计时器有效位数
    TACTL=TASSEL_1|ID_3|MC_2; //选择ACLK作为定时器源,分频系数为8,连续模式
    RTC_init();               //初始化RTC
}

void RTC_init(void)
{
    RTCCTL = RTCMODE|RTCBCD|RTCHOLD;    //RTC模式,BCD编码,暂停
    RTCSEC=0X00;                 //设置秒寄存器
    RTCMIN=0X00;                 //设置分寄存器
    RTCHOUR=0X00;                //设置时寄存器
    RTCCTL&=~RTCHOLD;            //使能RTC计数
}

2. 采用电性二极管控制系统复位: 

ISR(INT0_vect) {
    _NOP();
    PORTC |=(1<<PC1);
}

3. 采用WFI指令:

void WFI_sleep(void)
{
    GICR |= _BV(INT0);     // 允许 INT0 中断
    MCUCR |= _BV(ISC01);   // 设置下降沿触发中断
    set_sleep_mode(SLEEP_MODE_PWR_DOWN);
    sleep_enable();
    asm("wfi");
    sleep_disable();
}

Please accept my answer if it answers your question

davy445 注册会员
2023-02-26 14:18

This answer quotes ChatGPT

Here are some common methods:

1. Use battery power supply: Connect the VCC pin of the chip to the positive terminal of the battery, and connect the GND pin to the negative terminal of the battery, so that the battery can maintain the timing function of the chip even if the main power is disconnected. It should be noted that the voltage of the battery should meet the operating voltage requirements of the chip.

2. Use an external crystal oscillator: By connecting the external crystal oscillator to the CLK pins and GND pins of the chip, the timing function of the chip can be maintained in low power mode. In this case, the chip's power supply can be turned off, but the external crystal will continue to oscillate, providing a timing signal.

3. Use an external clock signal: If you have a clock source that is already running, you can connect that signal to the CLK pin of the chip, eliminating the need to use the chip's own oscillator. This approach is often used in application scenarios where synchronization with other systems or devices is required.

Note that regardless of the method, the CE pin of the chip needs to be kept high to ensure that the chip is always in working condition to maintain the timing function.

ddl223 注册会员
2023-02-26 14:18

NewBing

There are several ways for embedded microcontroller to maintain timing in low power mode, depending on the model and function of the microcontroller. In general, there are several common methods:

  • Uses an external crystal oscillator or an internal clock source as a low speed clock to provide a count signal for the real-time clock(RTC) or timer(TIM). In low power mode, only these peripherals are kept working, and other peripherals are turned off ① and ②.
  • Use the internal backup battery or supercapacitor to provide the minimum voltage to the single chip microcomputer. In standby mode, shut down all peripherals and the kernel power, and only keep the RTC working ②.
  • Use external interrupt signal or wake up pin to wake up the MCU, after wake up update time information ②.

Source: A Conversation with Bing, 2023/2/26

    < li >

    (1) the stm32 several low power modes of implementation and the difference - zhihu. < a href = "https://zhuanlan.zhihu.com/p/143352204" Target = "_blank" > < span > https://zhuanlan.zhihu.com/p/143352204 < / span > < / a > access time 2023/2/26.

  • (2) [STM32] Power control, low power mode(Example: Standby mode) _Yngz_Miao blog - CSDN _stm32 low-power routines. < a href = "https://blog.csdn.net/qq_38410730/article/details/80066542" Target = "_blank" > < span > https://blog.csdn.net/qq_38410730/article/details/80066542 < / span > < / a > access time 2023/2/26.

  • (3) An article, thoroughly understand the single chip clock architecture! - zhihu. < a href = "https://zhuanlan.zhihu.com/p/250022175" Target = "_blank" > < span > https://zhuanlan.zhihu.com/p/250022175 < / span > < / a > access time 2023/2/26.

dgy5811 注册会员
2023-02-26 14:18

For reference to GPT and my own ideas, in embedded systems, if you need to maintain timing in low power mode, you can consider the following methods:

1 Use a real-time clock(RTC) : A real-time clock is a low-power clock that is independent of the main system clock. In low power mode, the main system clock may shut down, but the RTC can still keep running. With RTC, you can keep the timing and calendar time accurate so that when the main system comes back up, you can update the time and date correctly. Many modern microcontrollers are equipped with RTC modules.

2 Use a Low Power timer(LPTIM) : A low power timer is a special timer that can continue timing in low power mode. They typically have very low power consumption and can use less power to maintain timing while still providing adequate accuracy.

3 Use Low power crystal oscillator(LPXO) : Low power crystal oscillator is a special kind of crystal oscillator with very low power consumption and high accuracy. They are commonly used in applications that require time accuracy in low power mode.
In addition to using a low-power timer, consider using an RTC(real-time clock) module. RTC is a chip designed specifically for timing and date recording, with the advantages of low power consumption, high precision, and not being affected by CPU load. In low power mode, the RTC can still continue timing and can be used for data transfer or processing by waking up the CPU. Therefore, you can use RTC to realize timing in low power mode. Specific implementation methods can refer to the relevant embedded single chip development documents.

dingdh13 注册会员
2023-02-26 14:18

Part of this answer references GPT, GPT_Pro to better solve the problem
To keep time in low power mode, you need to use something called a "low power timer." It can switch the MCU system from high power mode to low power mode, thus reducing the current consumption of the MCU system.

Low power timers can be divided into internal timers and external timers. The internal timer uses the MCU chip's internal clock signal to time, while the external timer uses an external electronic crystal oscillator or other external circuit to generate the clock signal, and then uses the MCU to time.

The low power timer works because when the timer's count reaches a preset value, an interrupt signal is generated that causes the MCU system to jump into low power mode. In low power mode, the MCU system is able to operate at a very low frequency and consume little power, but it can function normally and maintain its time count normally.

To use the low power timer, we first need to program the MCU in three aspects:

  1. Sets the initial value of the timer;
  2. Sets the interrupt priority of the timer;
  3. Sets the timer to interrupt the service function.

Setting the timer initial value and interrupt priority is a necessary step to realize low power timer. Before setting the interrupt service function, we can set the parameters required in the interrupt service function first. For example, we can set how the MCU enters low power mode, how long the MCU can operate normally after entering low power mode, or how long it takes to restart the MCU.

The last step is to set up the interrupt service function. In the interrupt service function, we can determine what the MCU will do based on the parameters set earlier. For example, when an interruption occurs, the MCU can enter a low-power mode or restart the previous operating mode.

Through the above method, we can use the low power timer to carry out the normal timing operation in the low power mode.
If the answer is helpful, please accept it.

daituzhe 注册会员
2023-02-26 14:18

Use the timing chip 1302/1307, but it's not energy hungry anymore.

cyk5597 注册会员
2023-02-26 14:18

Write based on Monster group and GPT:
In the low power mode of embedded microcontroller, in order to save power, it is usually to shut down some peripherals, reduce the main frequency and other measures, which will cause the timer to fail. To keep the clock ticking, the following methods are commonly used:

  • External clock: In low power mode, an external clock is used to keep the timer counting. For example, a low power clock crystal oscillator(LPO) or RTC(real-time clock) is used to provide the clock signal.
  • Internal low Power clock: Some microcontrollers have a built-in low power clock module that can provide a clock signal in low power mode. These clock modules typically have lower power consumption and less accuracy.
  • Autonomous wake up: Starts a timer or counter before entering low power mode, triggers an interrupt or wakes up the MCU when the counter overflows. This method can reduce the power consumption to a certain extent, but it needs to consider the accuracy of the timer and the delay of wake-up time.

requires long time timing, it is recommended to choose RTC(real-time clock) chip, which usually has higher accuracy and lower power consumption, can provide accurate clock signal. For example, DS1307, DS3231 and other RTC chips have good accuracy and stability.

About the Author

Question Info

Publish Time
2023-02-26 14:18
Update Time
2023-02-26 14:18