Information needed on S/W WATCHDOG Timer

For C and ASSEMBLY users to post questions and code snippets for programming in C and ASSEMBLY. And for any other C or ASM course related questions.

Moderators: Benj, Mods

Post Reply
keshavamurthy k.c
Posts: 18
Joined: Fri Feb 26, 2010 5:05 am
Contact:

Information needed on S/W WATCHDOG Timer

Post by keshavamurthy k.c »

Hi,
I want to use internel watchdog timer in PIC 16F946 controller using Flow code compiler.
Please provide me information how i need enable, disable and also i want to load value using configuration register.


Regards
Keshav
Last edited by keshavamurthy k.c on Thu Mar 25, 2010 1:58 pm, edited 1 time in total.

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: S/W WATCHDOG Timer

Post by Benj »

Hello,

You can simply enable using the configuration. Then use the C code "clear_wdt();" in your program to prevent the watchdog timing out and resetting your microcontroller.

keshavamurthy k.c
Posts: 18
Joined: Fri Feb 26, 2010 5:05 am
Contact:

Re: Information needed on S/W WATCHDOG Timer

Post by keshavamurthy k.c »

Hi,
thanks for replying .If i use clear_wdt(); what time the watch dog timer will reset.
And also i want to know how to change the watch dog reset timing value.

Regards
madhusdhan

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Information needed on S/W WATCHDOG Timer

Post by Benj »

Hello,

The watchdog prescaler setting is available as part of the option_reg register.

option_reg = option_reg | 0x08; //Assign prescaler to watchdog
option_reg = option_reg & 0xF8; //Mask off prescaler setting
option_reg = option_reg | 0x07; // Change prescaler setting to 1:128

The bottom line could be replaced with any of these

option_reg = option_reg | 0x07; // Change prescaler setting to 1:128
option_reg = option_reg | 0x06; // Change prescaler setting to 1:64
option_reg = option_reg | 0x05; // Change prescaler setting to 1:32
option_reg = option_reg | 0x04; // Change prescaler setting to 1:16
option_reg = option_reg | 0x03; // Change prescaler setting to 1:8
option_reg = option_reg | 0x02; // Change prescaler setting to 1:4
option_reg = option_reg | 0x01; // Change prescaler setting to 1:2
option_reg = option_reg | 0x00; // Change prescaler setting to 1:1

Again this code will need to be included in a C code icon at the start of your program.

keshavamurthy k.c
Posts: 18
Joined: Fri Feb 26, 2010 5:05 am
Contact:

Re: Information needed on S/W WATCHDOG Timer

Post by keshavamurthy k.c »

Hi,
I gone through PIC 16F946 data sheet if we want to use both internel watchdog timer and timer0 interupt we need to change configuration by selecting PSA bit.
In my project i want to scan key for every 1msec using timer0 interupt,if i enable watchdog timer also i am not getting Timer0 interupt scan data.
Can you please provide information how i need to handle.


Thanks & Regards
Keshav

User avatar
Benj
Matrix Staff
Posts: 15312
Joined: Mon Oct 16, 2006 10:48 am
Location: Matrix TS Ltd
Has thanked: 4803 times
Been thanked: 4314 times
Contact:

Re: Information needed on S/W WATCHDOG Timer

Post by Benj »

Hello,

You cannot use timer0 and the watchdog timer in your program without switching one or the other off. You can use the timer 1 instead of timer 0 if you wish, this should work fine.

keshavamurthy k.c
Posts: 18
Joined: Fri Feb 26, 2010 5:05 am
Contact:

information needed on capture signal form pin RC5/CCP1

Post by keshavamurthy k.c »

HI
I am using pic 16f946 microcontroller.i written custom interrupt for capture signal from input pin rc5/ccp1.
custom interrupt its working fine my problem is i am unable to copy from register ccpr1l and ccpr1h flow code variable.
i written code for copy from register ccpr1l and ccpr1h :
FCV_AVGCCPR=CCPR1L|(8<<CCPR1H);
after copy from ccpr1l and ccpr1h register value into flowcode varaiable AVGCCPRL value moving into UART directely .
i am getting some junk value .

please suggest me how to solve this problem

Post Reply