# Error with PIC10f and High Tech C

Status
Not open for further replies.

#### M3GAPL3X

##### Junior Member level 3
wdtcon htc

Hi Guys,

I am getting the following errors for some reason. Basically I am using a counter to keep track of how long a button is pressed. The WDT wakes up every 18 ms.

Code:
#include <htc.h>
#define BUTTON_INPUT GP0

//Sleep command
void Sleep(void)
{
#asm
sleep
#endasm
}

//main function
void main()
{
while(1) //do forever
{
CLRWDT(); //clear the watchdog timer
CheckButton(); //check button
WDTCON = 1; //enable the watchdog timer
Sleep(); //go to sleep for 18 ms
WDTCON = 0; //disable the watchdog timer
CheckButton(); //check button again
}
}

//Function: CheckButton
//Description: Check the state of RC2
//if active low, increment COUNTER. Check COUNTER to see if it is over 3 seconds. If so, provide power
//to main computer. If active high, reset COUNTER to 0

void CheckButton(void)
{
unsigned int COUNTER = 0;

if (BUTTON_INPUT == 0) //if an active low, increment the COUNTER
{
COUNTER++;
if (COUNTER >= 10000) //3
{
//SEND POWER TO HOST, IN TESTING, LIGHT AN LED
}
}
else //else - reset the COUNTER value back to 0 because button is not pressed
{
COUNTER = 0;
}
}

I get the following error:
19.1 undefined identifier "WDTCON"

#### millwood

wdtcon = 1 htc

that means WDTCON is undefined. you need to read the datasheet and the headerfile to see what is appropriate for the chip you are programming for.

#### betwixt

##### Super Moderator
Staff member
pic10f c program hi-tech

As far as I can remember, the watchdog timer cannot be enabled or disabled in software. The watchdog is controlled by a bit in the configuration fuses which have to be set when the device is programmed.

Brian.

#### M3GAPL3X

##### Junior Member level 3
hi-tech c sleep command

Thanks guys. I believe Brian is right. The PIC10f series has no software control of the WDT!!

Status
Not open for further replies.

Replies
5
Views
1K
Replies
4
Views
4K
Replies
0
Views
1K
Replies
4
Views
8K
Replies
4
Views
3K