C code function call error

Status
Not open for further replies.

skyrock

New Member
I built a simple Hitech C program but wierd problem happens when I make a function call. Below is the code and error msg. Someone please point out what did I do wrong?

It happens when I moved the initiating code to a function call and then i started getting error messages. but after a few tries with build and rebuilding code, I would be able to compile successfully..?

Code:
#include <htc.h>;
#include <pic1687x.h>
#include <pic.h>

__CONFIG(WDTDIS & HS & UNPROTECT & DEBUGDIS & LVPDIS 
& WRTDIS & DUNPROT & BORDIS & PWRTEN);

unsigned char INT_COUNT = 0;
unsigned char Seconds = 0;

void interrupt isr(void)
{
	if(TMR2IF) 
		{
			if(INT_COUNT!=249) INT_COUNT++;

			else 
			{
				if(RC0 == 0) RC0 = 1; else RC0 = 0;
				Seconds++;
				INT_COUNT = 0;
			}
		}
	TMR2IF = 0;
}


void main(void)
{
	init_main();
	while(1)
	{
	//	if(RC0 == 0) RC0 = 1;
	//	else RC0 = 0;
		
	};
}

void init_main(void)
{
	TRISB = 0x00;
	TRISC = 0x00;
	ADCON0 = 0x00;
	PR2 = 124;
	T2CON = 0b01001111;
	TMR2IE = 1;
	INTCON = 0b11000000;
}

Code:
Build C:\PIC\C programming 1st\16f877 LED AND BUTTON for device 16F877
Using driver C:\Program Files\HI-TECH Software\PICC\PRO\9.60\bin\picc.exe

Make: The target "C:\PIC\C programming 1st\LED AND BUTTON.p1" is out of date.
Executing: "C:\Program Files\HI-TECH Software\PICC\PRO\9.60\bin\picc.exe" --pass1 "C:\PIC\C programming 1st\LED AND BUTTON.C" -q --chip=16F877 -P --runtime=default --opt=default -g --asmlist "--errformat=Error   [%n] %f; %l.%c %s" "--msgformat=Advisory[%n] %s" "--warnformat=Warning [%n] %f; %l.%c %s" 
Warning [361] C:\PIC\C programming 1st\LED AND BUTTON.C; 30.1 function declared implicit int
Error   [984] C:\PIC\C programming 1st\LED AND BUTTON.C; 40.1 type redeclared
Error   [1098] C:\PIC\C programming 1st\LED AND BUTTON.C; 40.1 conflicting declarations for variable "init_main" (C:\PIC\C programming 1st\LED AND BUTTON.C:30)

********** Build failed! **********
 
You need to add a prototype at the top of your code,
Code:
__CONFIG(WDTDIS & HS & UNPROTECT & DEBUGDIS & LVPDIS 
& WRTDIS & DUNPROT & BORDIS & PWRTEN);

void init_main(void);            [COLOR="Red"]//added[/COLOR] 

unsigned char INT_COUNT = 0;
 
Last edited:
Thank you very much. I am trying to get the working to function. I studied C but this thread helped a lot. Thanks for skyrock and pommie.
 
Last edited:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…