完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨,
我觉得我已经阅读了一百万次参考手册,但我无法弄清楚如何让我的项目进入低功耗模式。 我正在驾驶一个带有计数器的液晶显示屏。我有两个外部开关来唤醒上下计数。我正在使用timer4来有希望定期醒来并做一些工作。 我需要两个低功耗模式,一个打开LCD,它只是唤醒处理按钮按下或timer4超时。 另一个低功耗模式将关闭LCD,仅在按下按钮时唤醒。它需要唤醒而不能复位,因为我不想丢失LCD的数量。 为了省电,我正在使用LSI时钟。 代码如下。任何想法将不胜感激。我是STM8的新手 主要() { CLK_CKDIVR = 0b0; //将时钟除以1 CLK_SWR = 0x02; //系统时钟是LSI(38kHz) CLK_SWCR | = 0x2; //告诉系统将时钟切换到SWR中定义的时钟 而(CLK_SWCR& 1); CLK_ICKCR& = 0b11111110; // HSI关闭 CFG_GCR | = 0b10; //在WFI / HALT之后未恢复主要上下文 lcd_init(); //首先这样做还是真的很慢PB_DDR = 0; //将引脚设置为输入。默认 //输入拉起来 PA_CR1 = 0x8C; PB_CR1 = 0xFF; PC_CR1 = 0xF7; PD_CR1 = 0x3C; PE_CR1 = 0xB6; PE_CR1 = 0x01; PB_CR2 = 0b110; // PB1和PB2中断使能 EXTI_CR1 = 0b101000; //端口1和2仅下降沿中断 CLK_PCKENR1 | = 0x04; //启用CLK到Timer4 TIM4_CR1 = 0b101; //启用Timer4 TIM4_IER = 1; // Timer4中断使能 TIM4_PSCR = 1; // CLK / 2(8)所以CLK为16而(CLK_SWCR& 1); {_asm('rim n');} //启用中断 而(1){ if(readyToSleep == 1){ readyToSleep = 0; CLK_PCKENR1 = 0; //禁用时钟到perfs CLK_PCKENR2 = 0; CLK_PCKENR3 = 0; EXTI_SR1 = 0; //清除中断 EXTI_SR2 = 0; TIM4_SR1 = 0; {_asm( 'HALT n');} } 其他{ {_asm( 'WFE n');} {_asm('JRA next n');} {_asm( '下: N');} // {_ ASM( 'WFI n');} } } } #halt #sleep #wfe#stm8l052c6 #wfi #lcd #low-power#stm8 以上来自于谷歌翻译 以下为原文 Hi, I feel like I've been through the reference manual a million times, but I cant figure out how to get my project into low power mode. I'm driving a LCD screen with a counter on it. I have two external switches to wake up count up and down. And I'm using timer4 to hopefully wake up periodically and do some work. I need two low power modes, one with the LCD on and it just wakes up to handle a button press or a timer4 timeout. The other low power mode will turn off the LCD and will only wake up on a button press. It needs to wake up and not reset because I don't want to lose count on the LCD. To save power I'm running off LSI clock. Code below. Any ideas would be greatly appreciated. I'm new to STM8 main() { CLK_CKDIVR = 0b0; //Div clock by 1 CLK_SWR = 0x02; //Sys clock is LSI (38kHz) CLK_SWCR |= 0x2; //Tell system to switch clocks to one defined in SWR while(CLK_SWCR & 1); CLK_ICKCR &= 0b11111110; //HSI Off CFG_GCR |= 0b10; //main context not restored after WFI/HALT lcd_init(); //Do this first or its really slow. PB_DDR = 0; //Set pins as Inputs. By default //INPUTS PULLED UP PA_CR1 = 0x8C; PB_CR1 = 0xFF; PC_CR1 = 0xF7; PD_CR1 = 0x3C; PE_CR1 = 0xB6; PE_CR1 = 0x01; PB_CR2 = 0b110; //PB1 and PB2 interrupt enable EXTI_CR1 = 0b101000; //Port1 and 2 to falling edge only interrupt CLK_PCKENR1 |= 0x04; //Enable CLK to Timer4 TIM4_CR1 = 0b101; //Enable Timer4 TIM4_IER = 1; //Timer4 interrupt enable TIM4_PSCR = 1; //CLK/2(8) so CLK div 16 while(CLK_SWCR & 1); {_asm('rimn');} //enable interrupts while (1){ if (readyToSleep == 1){ readyToSleep = 0; CLK_PCKENR1 = 0; //Disable clocks to perfs CLK_PCKENR2 = 0; CLK_PCKENR3 = 0; EXTI_SR1 = 0; //Clear interrupts EXTI_SR2 = 0; TIM4_SR1 = 0; {_asm('HALTn');} } else{ {_asm('WFEn');} {_asm('JRA nextn');} {_asm('next:n');} //{_asm('WFIn');} } } } #halt #sleep #wfe #stm8l052c6 #wfi #lcd #low-power #stm8 |
|
相关推荐
4个回答
|
|
|
好的,我真的需要帮助。我刚开始一个没有任何内容的新项目。一切都是默认的。我正在做的就是停止。
#include'STM8L052C6.h' void main(void) { {_asm( 'HALT n');} 而(1); 运行正常时,我正在绘制1.3mA电流。当我打电话给HALT时,我可以得到200uA左右。没有接近广告0.4uA的地方。我究竟做错了什么?在这一点上,我正在考虑勘误,但我没有看到任何迹象。请帮忙。有人有示例代码吗? 以上来自于谷歌翻译 以下为原文 Okay, I really need help. I just started a new project with nothing in it. Everything is default. All I am doing is calling halt. #include 'STM8L052C6.h' void main(void) { {_asm('HALTn');} while (1); }When running normal I'm drawing 1.3mA. When I call HALT, I can get around 200uA. No where near the advertised 0.4uA. What am I doing wrong? At this point I'm thinking errata, but I don't see anything noted anywhere. Please help. Anyone have example code? |
|
|
|
|
|
,
, 你好, 请找附件简单的示例项目。它是使用STVD IDE(Cosmic编译器)和STM8L的标准外设库开发的。 我在STM8L Discovery工具包上测试了这个应用程序。它包含STM8L152C6器件,但我相信你也可以在STM8L052C6上运行它。使用此代码,STM8L将进入暂停模式,它将从EXTI中断(PC1)唤醒。唤醒后,MCU将拨打PE7。 PC1连接到按钮,PE7连接到LED。此应用程序允许我在停止模式下达到0.4uA,请参见下图。 我的main.c文件如下所示: 问候 Szymon 以上来自于谷歌翻译 以下为原文 , , Hello, Please find attached a simple example project. It was developed using STVD IDE (Cosmic compiler) and Standard Peripheral Library for STM8L. I tested this applicaion on STM8L Discovery kit. It contains STM8L152C6 device, but I am sure you can run it also on your STM8L052C6. With this code STM8L will enter Halt mode and it will wake up from EXTI interrupt (PC1). After waking up MCU will togle PE7. PC1 is connected to push button and PE7 is connected to LED. This application allowed me to reach 0.4uA in Halt mode, please see the picture below. My main.c file looks like below:
Regards Szymon |
|
|
|
|
|
看看STM32L-DISCO的例子?
http://www.st.com/en/evaluation-tools/stm8l-discovery.html http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm8-embedded-software/stsw-stm8009.html http://www.st.com/en/microcontrollers/stm8l052c6.html http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm8-embedded-software/stsw-stm8016.html 以上来自于谷歌翻译 以下为原文 Looked at the STM32L-DISCO examples? http://www.st.com/en/evaluation-tools/stm8l-discovery.html http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm8-embedded-software/stsw-stm8009.html http://www.st.com/en/microcontrollers/stm8l052c6.html http://www.st.com/content/st_com/en/products/embedded-software/mcus-embedded-software/stm8-embedded-software/stsw-stm8016.html |
|
|
|
|
|
谢谢。我能够使用该示例代码。我注意到如果我编译'Debug',我仍然只能让它工作,因为如果我编译'Release'并将其加载到单元上,它永远不会进入低功耗状态。但这已经足够了。谢谢。
以上来自于谷歌翻译 以下为原文 Thanks. I was able to get it to work with that example code. I've noticed I can still only get it to work if I compile for 'Debug' because if I compile for 'Release' and load that onto the unit, it never goes into low power. But this is good enough for now. Thanks. |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1453 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1502 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3649 浏览 1 评论
3842 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2461 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
727浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
663浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 10:39 , Processed in 1.233599 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
2093