tienchuan
Joined: 25 Aug 2009 Posts: 175
|
[Help] Setup WDT in PIC18F4680 |
Posted: Wed Mar 18, 2015 12:46 am |
|
|
Hi
I have a problem when tried to setting WDT on PIC18F4680
In main program, i also used timer 0, and I can't config WDT with " setup_wdt() with another parameter, I can only setup with "WDT_512ms"
My config "
Code: |
#include "18F4680_me.h" #fusesH4,PUT,PROTECT,NODEBUG,NOLVP,WDT256,NOPBADEN,MCLR,BROWNOUT,BORV28
#use delay(clock=40000000)
#use rs232(baud=9600, xmit=PIN_C6, rcv=PIN_C7, errors)
|
-timer0 setup
Code: |
set_timer0(62);
setup_timer_0 (RTCC_INTERNAL | RTCC_8_BIT | RTCC_DIV_256);
|
- main code
Code: |
void main(void)
{
.
.
.
setup_wdt(WDT_ON|WDT_512mS); // can't config with another parameters without WDT_512ms
restart_wdt();
for(;;) // main loop
{
restart_wdt();
.
.
.
}
}
|
I'm using CCS C ver 5.021
Pls show me a problems when setup with WDT, is it conflict with timer0 ?
Thanks. _________________ Begin Begin Begin !!! |
|
PCM programmer
Joined: 06 Sep 2003 Posts: 21708
|
|
Posted: Wed Mar 18, 2015 1:30 am |
|
|
The 18F4680 data sheet says:
Quote: |
24.2 Watchdog Timer (WDT)
24.2.1 CONTROL REGISTER
Register 24-14 shows the WDTCON register. This is a
readable and writable register which contains a control
bit that allows software to override the WDT enable
Configuration bit, but only if the Configuration bit has
disabled the WDT.
|
This means if you want to use setup_wdt(), you must put NOWDT (only)
in the #fuses. Remove the WDT256 and replace it with NOWDT. |
|