View previous topic :: View next topic |
Author |
Message |
RNR107
Joined: 19 Dec 2014 Posts: 23
|
WDT on PIC18F46K22 |
Posted: Fri Mar 01, 2019 7:11 am |
|
|
Hi all,
I am using:
pcwhdupd Version 5.82.20.10
PIC18F46K22
I am trying to add a WDT in my code so I went and try the CCS example:
ex_wdt18.c
I just replace the clock with clock=64MHz,crystal=16MHz and replace the device with PIC18F46K22.
I was expecting the PIC to reset itself if I didn't press a key... But nothing is happening. Is there anything special about the PIC18F46K22 ?
Code: |
#include <18F46K22.h>
#use delay(clock=64MHz,crystal=16MHz)
#USE rs232(baud=9600, UART1, errors, stream=to_Screen)
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_ON);
while(TRUE)
{
restart_wdt();
printf("Hit any key to avoid a watchdog timeout.\r\n");
getc();
}
}
|
Thank you!
RNR |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9274 Location: Greensville,Ontario
|
|
Posted: Fri Mar 01, 2019 7:27 am |
|
|
You need to build in 'release' mode and NOT be connected to an ICD or debugger.
IE: PIC has to be 'standalone'.....
if you are connected to icd/debugger, there's software that shuts off the wdt. |
|
|
RNR107
Joined: 19 Dec 2014 Posts: 23
|
|
Posted: Fri Mar 01, 2019 9:20 am |
|
|
Hi temtronic,
That's a good one! I didn't know that.... Thanks!
Found an other problem (and the solution) I think there is a mistake in the CCS 18F46K22.h file. WDT_TIMEOUT is defined as 7 but I am getting 15 from RESTART_CAUSE() ??? |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9274 Location: Greensville,Ontario
|
|
Posted: Fri Mar 01, 2019 9:38 am |
|
|
Unfortunately this PC (W7) has decided to not let me play with PICs since Wednesday. No amount of remove/add/pray to the Great PIC in the sky has got it 'up and running'.
BTW I've never used the WDT on the 46k22, though it is my favorite.
Jay |
|
|
|