关于PIC单片机的“休眠”和“唤醒”

2020-02-06 10:13发布

关于PIC单片机的“休眠”和“唤醒”自己还是不太会用。希望各位大虾能给点指导。
现在主要是用PIC12F635单片机。用其中一个引脚GP0做为按键输入,其中一个引脚GP4作为输出。要达到的效果就是:平时都是“休眠”状态,当有按键按下时,单片机立即“唤醒”,GP4开始发出某段波形。就是想问一问这“休眠”与“唤醒”,具体怎么设置,希望有朋友写一小段用C的休眠和唤醒程序。让我能入个门。
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。
24条回答
millwood0
2020-02-07 22:53
the code sets up the wdt to wake the mcu up ever 160ms.

Once the mcu wakes up, it sets up the port / wdt, and then goes into the main while() loop.

in the main while loop, it checks to see if it is waking up. if it is, it increments a counter (wdt_counter). and then it outputs the wdt_counter on LED_PORT (GPIO here). after that, it goes into an infinite loop.

what you will see is that GPIO's pins will increment with each reset (every 160ms), with the exception that GPIO3 will not change as it is an input only pin on this mcu.

the code is compiler so that it does NOT clear data segments (bss Psects in Hi-Tech PICC talk).

here is the sim.

hope it helps.



(原文件名:12f675 wdt.PNG)

一周热门 更多>