CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to support@ccsinfo.com

Watchdog timer problem in PIC 18f25k20

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
nehallove



Joined: 16 Jan 2008
Posts: 61

View user's profile Send private message

Watchdog timer problem in PIC 18f25k20
PostPosted: Wed Nov 04, 2009 6:27 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Wed Nov 04, 2009 6:58 pm     Reply with quote

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

View user's profile Send private message

PostPosted: Thu Nov 05, 2009 5:57 pm     Reply with 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


these are the fuses it sets.

nehal
_________________
nehal
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Thu Nov 05, 2009 6:04 pm     Reply with quote

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.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group