View previous topic :: View next topic |
Author |
Message |
Graham Webb
Joined: 18 Apr 2008 Posts: 9
|
|
Posted: Tue Aug 10, 2010 3:23 am |
|
|
Was this resolved because I am having the same problem with the following code:
Code: |
#include <C:\Program files\PICC\devices\16f876a.H>
#include <C:\Program files\PICC\drivers\stdio.h>
#fuses HS,WDT,NOPROTECT,NOLVP
#define GREEN PIN_C1 //pin C1 = out green LED
#define BLUE PIN_C2 //pin C2 = out blue LED
SET_TRIS_C(0b00000000);
void main()
{
if (restart_cause() == WDT_TIMEOUT)
{
output_high(BLUE);
}
setup_wdt(WDT_2304MS);
while(TRUE)
{
output_high(GREEN);
output_low(GREEN);
}
}
|
This uses a 20 MHz crystal, the green LED toggles rapidly (370 kHz) and the blue LED never comes on. I'm expecting the blue LED to come on once after 2.3 seconds.
I'm using MPLab 8.53 with the CCS c-compiler 3.223.
I did find that the configuration bit for the WDT in MPLab is off and reverts to off when I compile this, so I'm going to try manually switching it on now. |
|
|
Graham Webb
Joined: 18 Apr 2008 Posts: 9
|
|
Posted: Tue Aug 10, 2010 3:40 am |
|
|
Whatever I do the WDT configuration bit reverts to off, very odd. Any ideas? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Tue Aug 10, 2010 11:49 am |
|
|
Are you trying to run this program in Debug mode, with an ICD ?
The ICD2 Help file says:
Quote: |
Debugger Limitations
The Watchdog Timer (WDT) cannot be used when debugging.
|
So either the compiler and/or MPLAB is turning it off for you. It won't
let you enable it in Debug mode. |
|
|
Graham Webb
Joined: 18 Apr 2008 Posts: 9
|
|
Posted: Tue Aug 10, 2010 12:07 pm |
|
|
Thanks PCM Programmer, that solved it! |
|
|
|