View previous topic :: View next topic |
Author |
Message |
lpln852
Joined: 22 Jan 2011 Posts: 3
|
PIC12F629 WD+sleepmode no Working |
Posted: Mon Nov 13, 2017 9:36 am |
|
|
why this line have error in CCS ?
setup_wdt(WDT_ON);
setup_wdt(WDT_2304MS|WDT_DIV_16); //~2.3 s reset
Please send example Source code for PIC12f629 WDT and sleep mode. |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Mon Nov 13, 2017 9:50 am |
|
|
Have a look at the header for that PIC.
12F629.h
Are those 3 options available ?? |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Mon Nov 13, 2017 11:19 am |
|
|
Also look at the data sheet.
What is the longest time the watchdog is quoted to give?. 2304mSec....
Does the watchdog on this chip have an option to disable in software?. No.....
CCS can only give you options the chip actually has. |
|
|
lpln852
Joined: 22 Jan 2011 Posts: 3
|
|
Posted: Mon Nov 13, 2017 11:31 am |
|
|
Thanks
How about sleep mode ? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9229 Location: Greensville,Ontario
|
|
Posted: Mon Nov 13, 2017 12:08 pm |
|
|
Yes that PIC has a sleep mode according to the datasheet, special features chapter. It's also noted in the device header that CCS supplies. |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19518
|
|
Posted: Mon Nov 13, 2017 12:59 pm |
|
|
Code: |
#include <12F629.h>
#FUSES WDT //Watch Dog Timer
#FUSES INTRC_IO //Internal RC Osc, no CLKOUT
#FUSES NOBROWNOUT //No brownout reset
#use delay(int=4000000)
void main()
{
setup_wdt(WDT_2304MS); //program 2 sec (approx)
setup_comparator(NC_NC);
while (TRUE)
{
output_toggle(PIN_A0);
sleep();
delay_cycles(1); //nop instruction after sleep
}
}
|
This will toggle pin A0 just over every couple of seconds (but beware the WDT time is _very_ approximate - about 1.7 secs to about 2.6 secs), while the chip will sleep almost all the time. |
|
|
|