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 CCS Technical Support

CAN'T MAKE THE WATCHDOG WORKS ON A 16F877

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



Joined: 12 Sep 2003
Posts: 12
Location: Val-d'or, Quebec, Canada

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

CAN'T MAKE THE WATCHDOG WORKS ON A 16F877
PostPosted: Fri Mar 12, 2004 1:32 pm     Reply with quote

Hi! I'm trying to learn how the Watchdog Timer is working on a 16f877. I tried the ex_wdt.c example without any success. All I want to do is to have the processor being restarted if its WDT is nor cleared. The only thing I think could interfer would be that I'm using a bootloader to dowload programms to my 16F877.

If I don't press any key ont hyperterminal, then I get nothing. If I press the reset button on my 16F877, I will have the message Normal power up!. But I never see the Restarted processor because of watchdog timeout! message.

Can anybody help me? Question

Code:

#if defined(__PCB__)
#include <16c56.h>
#fuses HS,WDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9600, xmit=PIN_A3, rcv=PIN_A2)  // Jumpers: 11 to 17, 12 to 18

#elif defined(__PCM__)
#include <16F877.h>
#fuses HS,WDT,NOPROTECT,NOLVP
#use delay(clock=20000000)
#use rs232(baud=9200, xmit=PIN_C6, rcv=PIN_C7)  // Jumpers: 8 to 11, 7 to 12

#endif

void main()   {

   prescaler = 1;

   switch ( restart_cause() )
   {
      case WDT_TIMEOUT:
      {
         printf("\r\nRestarted processor because of watchdog timeout!\r\n");
         break;
      }
      case NORMAL_POWER_UP:
      {
         printf("\r\nNormal power up!\r\n");
         break;
      }
   }

   setup_wdt(WDT_2304MS);

   while(TRUE)
   {
      restart_wdt();
      printf("Hit any key to avoid a watchdog timeout.\r\n");
      getc();
   }
}
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 12, 2004 1:45 pm     Reply with quote

The bootloader will not set the #fuses (config bits).

This line will have no effect.
#fuses HS,WDT,NOPROTECT,NOLVP

The config bits were set when you programmed the
bootloader code into the PIC originally, with a PicStart-Plus
or Warp-13A, etc.

The bootloader can't change them.
peterfreedom



Joined: 12 Sep 2003
Posts: 12
Location: Val-d'or, Quebec, Canada

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

What purpose do #fuse is suppose to serve?
PostPosted: Fri Mar 12, 2004 1:55 pm     Reply with quote

I'm using the EPICWin programmer from MicroEngineering Lab to programm the Bootloader on the 16F877. Then I solder the chip on the board. Then I use a serial Cable with a MAX232 to simply download the program I'm experimenting with.

What is the purpose of the #fuse instruction if this is the Programmer that have the control on it anyway? Thanks.
PCM programmer



Joined: 06 Sep 2003
Posts: 21708

View user's profile Send private message

PostPosted: Fri Mar 12, 2004 2:03 pm     Reply with quote

The #fuses line is used with programmers that support
writing the config bits to the PIC. (Such as PicStart-Plus, etc.).

Your bootloader does not support that (and can't support it)
so the #fuses line is ignored.
peterfreedom



Joined: 12 Sep 2003
Posts: 12
Location: Val-d'or, Quebec, Canada

View user's profile Send private message Send e-mail Yahoo Messenger MSN Messenger

PostPosted: Fri Mar 12, 2004 2:19 pm     Reply with quote

You are right. Here is the information about the Bootloader from the Author web Page. http://www.ehl.cz/pic/pic_e.htm

PIC downloader
Free PIC downloader version 1.08. Its features:
compatible with the HI-TECH's or Shane Tolmie's bootloader for the PIC16F87x processors
runs under Windows 9x/ME/NT/2000
baud rate selection from 2400 to 56000 Bd
serial port selection COM1-6
works with EEPROM data in the hex file (Shane Tolmie's or my bootloader)
doesn't send config word at 0x2007 or ID word to bootloader
remembers last settings
inclusive of the source code
PIC downloader controls RESET and trigger pin of microcontrollers
inclusive of the assembler bootloader for all non "C" programmers. The bootloader is very easy recompilated for various microcontrollers, pin/time triggering, baud rates and quartz frequencies. You need only free Microchip's MPLAB with MPASM.

So I guest that using a bootloader has some serious limitation, not to say irritations. Thank you very much.
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