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).
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)
原来是编译器的问题,编译的时候clear bss不要打开,否则编译系统编译的时候会在初始化之前自动加上一些对RAM清零的代码,这样每次复位都会把RAM数据都清零,我也是仔细检测了汇编代码才发现的,我用的是PICC 9.8.
非常感谢 millwood0!!
一周热门 更多>