View previous topic :: View next topic |
Author |
Message |
peterfreedom
Joined: 12 Sep 2003 Posts: 12 Location: Val-d'or, Quebec, Canada
|
CAN'T MAKE THE WATCHDOG WORKS ON A 16F877 |
Posted: Fri Mar 12, 2004 1:32 pm |
|
|
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?
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();
}
} |
|
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Mar 12, 2004 1:45 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
peterfreedom
Joined: 12 Sep 2003 Posts: 12 Location: Val-d'or, Quebec, Canada
|
What purpose do #fuse is suppose to serve? |
Posted: Fri Mar 12, 2004 1:55 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Fri Mar 12, 2004 2:03 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
peterfreedom
Joined: 12 Sep 2003 Posts: 12 Location: Val-d'or, Quebec, Canada
|
|
Posted: Fri Mar 12, 2004 2:19 pm |
|
|
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. |
|
![](templates/subSilver/images/spacer.gif) |
|