View previous topic :: View next topic |
Author |
Message |
brett777_L
Joined: 16 Sep 2008 Posts: 7
|
want to give up .. WDT |
Posted: Sun Sep 28, 2008 7:47 pm |
|
|
Have worked on WDT for 3 weeks already but still can't make it work....
Really want to give up ..
>.<
Pls help me, i need some tips and do a last try . PIC16F72 .................. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
|
brett777_L
Joined: 16 Sep 2008 Posts: 7
|
|
Posted: Sun Sep 28, 2008 9:15 pm |
|
|
Hi PCM, I have started with sample program from
C:\Program Files\PICC\Examples
This sample program is keeping reset every 2 sec, and i read those posts you suggested, i tried to add restart_wdt into program, but it still keeps resetting.
Code: |
#include <16F72.h>
#fuses RC,WDT,PROTECT
#use delay(clock=4000000,[b]restart_wdt [/b])
void main() {
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();
}
}
|
i don't know why watchdog is not cleared in this program ?
i think this is the same happening in below post:
http://www.ccsinfo.com/forum/viewtopic.php?t=25062 |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 28, 2008 10:16 pm |
|
|
How do you know it resets ? You don't have any printf statements
or any LEDs to show the progress of the program.
Are you running this program on a board ? Or are you running it in a
simulator, or an emulator such as Proteus ? |
|
|
brett777_L
Joined: 16 Sep 2008 Posts: 7
|
|
Posted: Sun Sep 28, 2008 10:25 pm |
|
|
I'm running on a board, all components (LED, power supply connected with DMM)shut down and reset every 2 sec. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 28, 2008 10:39 pm |
|
|
Did you build this board yourself, or did you buy the board ?
If you bought it, then post the manufacturer and name or model number
of the board.
If you built it yourself, have you ever been able to run any program
successfully on this board ? |
|
|
Guest
|
|
Posted: Sun Sep 28, 2008 11:39 pm |
|
|
This is a prototype board i made in school time, it works with current program if no watchdog. If i add in above wdt code, the whole system keeps resetting every 2 sec.. |
|
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Sun Sep 28, 2008 11:55 pm |
|
|
I'm going to give up on helping, because your program doesn't output
to any LED. If it doesn't have the WDT enabled, it won't do anything
except silently sit in a while() loop forever. There's no indication that
it "works" or does anything. It's not a test program. I'm giving up. |
|
|
brett777_L
Joined: 16 Sep 2008 Posts: 7
|
|
Posted: Mon Sep 29, 2008 12:19 am |
|
|
that's great ! i also give up
i'm first timer in C and CCS, no teacher is tough, just study micro processor 2 weeks .
anyway, give up ! cheers ! |
|
|
Wayne_
Joined: 10 Oct 2007 Posts: 681
|
|
Posted: Mon Sep 29, 2008 2:32 am |
|
|
So, how do you know it has reset ? Exactly!
Your printf statements are commented out, you don't appear to be controlling an LED, you don't have an #USE RS232 statement so if you did uncomment the printf's they would most likely would still fail!
Are you trying to monitor it using the debugger ? |
|
|
Rohit de Sa
Joined: 09 Nov 2007 Posts: 282 Location: India
|
|
Posted: Mon Sep 29, 2008 2:52 am |
|
|
Hey brett777_L,
C'mon, don't give up so easily. PCM Programmer was just indicating that to get help on the forum you would have to make it clear to people what you are attempting to do.
So, though spoon feeding is not recommended, I'm posting what your code should look like.
Code: |
#include <16F72.h>
#fuses RC,WDT,PROTECT
#use rs232(baud=9600, xmit=pin_a2,rcv=pin_a3)
#use delay(clock=4000000)
void main() {
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();
}
} |
You seem to be using an RC oscillator. Do note that RC oscillators aren't recommended for RS232. Try using a 4MHz XT or a higher speed HS.
Rohit |
|
|
|