View previous topic :: View next topic |
Author |
Message |
nehallove
Joined: 16 Jan 2008 Posts: 61
|
Watchdog timer problem in PIC 18f25k20 |
Posted: Wed Nov 04, 2009 6:27 pm |
|
|
Hi Everyone,
I have been trying to setup watchdog timer on my code. Before doing that I tried to write the test program to test it.
I am using chip "18F25K20"
compiler version is "4.083"
Code: |
#include <18F25K20.h>
#fuses INTRC_IO, WDT, NOLVP
#use delay(clock=1000000)
//======================================
void main()
{
setup_oscillator(OSC_1MHZ);
setup_wdt(WDT_ON);
//setup_counters(RTCC_INTERNAL, RTCC_DIV_1);
output_low(PIN_C2);
delay_ms(100);
output_high(PIN_C2);
delay_ms(100);
output_low(PIN_C2);
while(1);
}
|
As per datasheet default watchdog timer period is 4 mS if I don't setup any postscaler. But watchdog timer is taking long time to do system reset. I just simply download the code and see the output from the prototype board port on the oscilloscope.
Even setup counter hasn't any effect on the code either.
Am I doing something wrong? Please let me know.
Thank you all in advance.
nehal _________________ nehal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Nov 04, 2009 6:58 pm |
|
|
Look at the actual Config bit settings that the compiler has created.
They're given at the end of the .LST file. The .LST file will be in your
project directory after a successful compilation.
If the WDT time selected by the compiler is not what you expected,
then look in the .H file for your PIC, near the top, and choose the
correct WDT fuse. Put it into your #fuses statement. |
|
|
nehallove
Joined: 16 Jan 2008 Posts: 61
|
|
Posted: Thu Nov 05, 2009 5:57 pm |
|
|
Configuration Fuses:
Word 1: 0800 NOIESO NOFCMEN INTRC_IO
Word 2: 1F1E BROWNOUT WDT BORV18 PUT WDT32768
Word 3: 8B00 PBADEN CCP2C1 NOLPT1OSC MCLR RESERVED NODELAYINTOSC
Word 4: 0081 STVREN NODEBUG NOLVP NOXINST RESERVED
Word 5: C00F NOPROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTC NOWRTB
Word 7: 400F NOEBTR NOEBTRB
these are the fuses it sets.
nehal _________________ nehal |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Thu Nov 05, 2009 6:04 pm |
|
|
Quote: |
Configuration Fuses:
Word 1: 0800 NOIESO NOFCMEN INTRC_IO
Word 2: 1F1E BROWNOUT WDT BORV18 PUT WDT32768
Word 3: 8B00 PBADEN CCP2C1 NOLPT1OSC MCLR RESERVED NODELAYINTOSC
Word 4: 0081 STVREN NODEBUG NOLVP NOXINST RESERVED
Word 5: C00F NOPROTECT NOCPD NOCPB
Word 6: E00F NOWRT NOWRTD NOWRTC NOWRTB
Word 7: 400F NOEBTR NOEBTRB |
There's the default delay time (in bold).
32768 x 4ms = 131072ms = 131 seconds.
Look in the 18F25K20.h file (near the top) to see the available WDT
delay fuses. Choose the one you want and put it into your #fuses
statement. |
|
|
|