Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Error with PIC10f and High Tech C

Status
Not open for further replies.

M3GAPL3X

Junior Member level 3
Joined
Jul 29, 2009
Messages
30
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
1,521
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"
 

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.
 

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.
 

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.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top