Testing for watchdog timeout on 16F616

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
medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Testing for watchdog timeout on 16F616

Post by medelec35 »

Hi All,
Using Hi-tec I wanted to determine if cause of firmware resetting was watchdog time out or not.
So at the beginning of main I placed:
Checking for WDT.png
(10.09 KiB) Downloaded 3153 times
In the hope to test watchdog timeout.
Data sheet shows if watch timeout occurred, then TO bit of status would change to 0
So I enabled WDT and placed while(1) loop.
I am getting a load of 1's sent via RS232,
so WDT register is read as 1 and not expected 0.
Not sent reset WDT command prior to reading status bit4 , So status(4) is not acting on a clear watchdog command

So after a WDT reset does anyone know why status bit TO is set at 1 when data sheet shows as NOT TO?
I.e. default for status bit 4 = 0 .
Thanks :)

Martin
Martin

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: Testing for watchdog timeout on 16F616

Post by Benj »

Hi Martin,

Hm thats an odd one. I wonder if its anything to do with how you are reading the bit from the register.

Could you try this C code instead.

FCV_PREV_FINAL_SPEED = test_bit(STATUS, TO);

or

FCV_PREV_FINAL_SPEED = STATUSbits.TO;

The status register might be named slightly differently. Eg maybe status_reg.

Section 11.6 of the datasheet has a bit more information but not a lot.

medelec35
Matrix Staff
Posts: 9520
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2585 times
Been thanked: 3815 times
Contact:

Re: Testing for watchdog timeout on 16F616

Post by medelec35 »

Thanks for your reply Ben,
I tried the top option and just all number 2's was displayed.
That was odd since it's a bit that is being tested, was expecting a 0 or 1

Tried different combinations for the second option you gave, and all combinations would not allow flowchart to compile.

Martin
Martin

Post Reply