View previous topic :: View next topic |
Author |
Message |
mhz1575
Joined: 20 Jun 2008 Posts: 14
|
Failure on watchdog pic18f46k80 |
Posted: Mon Mar 17, 2014 2:23 pm |
|
|
Hello folks,
I have a problem on watchdog because my feeling it that doesn't work.
I forced a problem on the software and the micro didn't reboot.
Is my code wrong?
CCS PCH 5.0
Thank you
Mario
Code: |
#include <18F46K80.h>
#device ADC=10 // 10 Bit 0..1023
#FUSES WDT
#FUSES WDT512
#FUSES NOXINST //Extended set extension and Indexed
#FUSES NOBROWNOUT //No brownout reset
#use delay(crystal=20mhz)
.........
void main()
{
boot();
setup_wdt(WDT_ON);
while(true)
{
.............
restart_wdt(); |
|
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19485
|
|
Posted: Mon Mar 17, 2014 3:03 pm |
|
|
Other possibility is the old MPLAB one. A search here will find this. |
|
|
mhz1575
Joined: 20 Jun 2008 Posts: 14
|
|
Posted: Tue Mar 18, 2014 3:58 am |
|
|
Hi, I read the post in the past but do not solve my problem.
Can someone tell me which string have I to write for use the wdt on my pic?
Fuse, enable and disable.
I assume that mine is wrong where I don't know.
On the forum I found these simple instructions, the same of mine but on my micro doesn't works.
Code: |
#include <18F66J60.h>
#fuses HS
#fuses WDT,WDT512
#use delay(clock=10M)
void main()
{
SETUP_WDT(WDT_ON);
while(1)
{
delay_ms(32000);
}
} |
Thank you for your help |
|
|
drh
Joined: 12 Jul 2004 Posts: 192 Location: Hemet, California USA
|
|
Posted: Tue Mar 18, 2014 8:56 am |
|
|
#FUSES WDT_SW _________________ David |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19485
|
|
Posted: Tue Mar 18, 2014 12:34 pm |
|
|
With the watchdog enabled, as you show it should be triggering. I go back to my possibility that this is the old MPLAB problem. Are you compiling through MPLAB?.
If you are, you need to ensure you are setting this to compile for 'release' It defaults to 'debug', and this overrides (turns off) the watchdog... |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Wed Mar 19, 2014 5:16 am |
|
|
Thread title: Failure on watchdog pic18f46k80
Code: #include <18F66J60.h> |
|
|
mhz1575
Joined: 20 Jun 2008 Posts: 14
|
|
Posted: Wed Jun 11, 2014 1:14 am |
|
|
Hello folks,
I'm coming back to these issue because after many test following all your indications the situation doesn't change.
The situation is this:
My compiler enviroment is only a CCS 5
I wrote code both for PCM or PCH but didn't works
Due to your experience is better to use Microchip ide mplab + ccs compiler?
Other suggest to obtain a watchdog?
Thank you |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Wed Jun 11, 2014 1:25 am |
|
|
How do you know the watchdog reset is not happening? |
|
|
mhz1575
Joined: 20 Jun 2008 Posts: 14
|
|
Posted: Wed Jun 11, 2014 11:13 am |
|
|
I know for two reasons:
First on my effective program where I have a modem that didn't answer on the uart blocking on a getc.
Second using a very simple sw where there isn't a reboot by wdt.
Consider that to write this test sw I have used the CCS wizard.
I'm frustrated....
Code: |
#include <18F46K80.h>
#device ADC=16
#FUSES WDT //Watch Dog Timer
#FUSES WDT512 //Watch Dog Timer uses 1:512 Postscale
#FUSES NOXINST //Extended set extension and Indexed Addressing mode disabled (Legacy mode)
#FUSES NOBROWNOUT //No brownout reset
#use delay(crystal=20000000)
#use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GPS,restart_wdt,errors)
void main()
{
switch ( restart_cause() )
{
case WDT_TIMEOUT:
{
fprintf(GPS,"\r\nRestarted processor because of watchdog timeout!\r\n");
break;
}
case NORMAL_POWER_UP:
{
fprintf(GPS,"\r\nNormal power up!\r\n");
break;
}
}
setup_wdt(WDT_ON);
while(TRUE)
{
//TODO: User Code
restart_wdt();
printf("Hit any key to avoid a watchdog timeout.\r\n");
getc();
}
} |
|
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19485
|
|
Posted: Wed Jun 11, 2014 11:42 am |
|
|
It won't give a restart on a getc, since you are turning that off. That is what 'restart_wdt' does in the #use RS232. It adds code to the RS232 routines to prevent the watchdog triggering in these.... |
|
|
oxo
Joined: 13 Nov 2012 Posts: 219 Location: France
|
|
Posted: Wed Jun 11, 2014 12:02 pm |
|
|
And.. If you are testing in Debug mode, watchdog is disabled. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 11, 2014 12:29 pm |
|
|
Quote: | Consider that to write this test sw I have used the CCS wizard.
I'm frustrated.... |
Expanding on Ttelmah's comment (I was testing this in hardware at
the same time):
You edited the CCS example file, ex_wdt18.c and added the parameter
shown below in bold:
Quote: | #use rs232(baud=115200,parity=N,xmit=PIN_C6,rcv=PIN_C7,bits=8,stream=GPS,restart_wdt,errors) |
This is the reason why your program is not working. Remove the restart_wdt parameter. |
|
|
mhz1575
Joined: 20 Jun 2008 Posts: 14
|
|
Posted: Wed Jun 11, 2014 12:33 pm |
|
|
Opps, sometimes happen to do wrong after many many test.
Anyway removing restart_wdt from uart declaration the situation didn't change on the test program attacched in the last post. The micro didn't restart.... ufff ufff ufff
No debug, sure.
Could be a problem on the 18f46k80.h files? |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Jun 11, 2014 12:51 pm |
|
|
1. Are you testing this WDT program on a real hardware board ?
2. Did you buy the board ? Or did you build it yourself ?
If you bought the board, post a link to the website for the board.
If you made the board by yourself, post a link to the schematic.
3. Post your CCS compiler version. Example of version numbers:
http://www.ccsinfo.com/devices.php?page=versioninfo |
|
|
|