DelayMS fonksiyonuna bağlı hata?

Başlatan SCHOTTKY, 21 Temmuz 2006, 16:41:00

SCHOTTKY

Yapmış olduğum projeyi derledim hiçbir hata yok ancak, DelayMS komutu için "function declared implicit int" ve "unreachable code" diyor derleyici.

Size kodun tamamını ve aynı klasördeki delay.h ve delay.c dosyalarını yapıştırıyorum.

#include <pic.h>
#include "delay.c"
#include <stdio.h>

#define Output RB7 //Pulse Output


#define Buzzer RA2 // Buzzer output
#define Start  RA3 //Coded pin B for BCD code input
#define Stop RA4 //Coded pin C
#define Ri RA0 //Rotary Encoder In
#define Ro RA1 //Rotary Endoder Out

unsigned int bmode, brpt, countM, countL, countX, started, a, b, d, proceed, rok, i, in, z = 0;


getBin()
{

	//before process

	switch(countL)
	{
		//RB0 is MSB, RB3 is LSB
		case 0: RB0=0; RB1=0; RB2=0; RB3=0; break;
		case 1: RB0=0; RB1=0; RB2=0; RB3=1; break;
		case 2: RB0=0; RB1=0; RB2=1; RB3=0; break;
		case 3: RB0=0; RB1=0; RB2=1; RB3=1; break;
		case 4: RB0=0; RB1=1; RB2=0; RB3=0; break;
		case 5: RB0=0; RB1=1; RB2=0; RB3=1; break;
		case 6: RB0=0; RB1=1; RB2=1; RB3=0; break;
		case 7: RB0=0; RB1=1; RB2=1; RB3=1; break;
		case 8: RB0=1; RB1=0; RB2=0; RB3=0; break;
		case 9: RB0=1; RB1=0; RB2=0; RB3=1; break;
	}



	switch(countM)
	{
		//RB4is MSB, RB6 is LSB
		case 0: RB4=0; RB5=0; RB6=0; break;
		case 1: RB4=0; RB5=0; RB6=1; break;
		case 2: RB4=0; RB5=1; RB6=0; break;
		case 3: RB4=0; RB5=1; RB6=1; break;
		case 4: RB4=1; RB5=0; RB6=0; break;
		case 5: RB4=1; RB5=0; RB6=1; break;
		case 6: RB4=1; RB5=1; RB6=0; break;
		case 7: RB4=1; RB5=1; RB6=1; break;
	}

}



load(void)
{

if(EEPROM_READ(0)!=NULL)
{

countL = EEPROM_READ(0);
countM = EEPROM_READ(1);
countX = (countM*10)+(countL);
getBin();

}

}



beep(bmode, brpt)
{

if(bmode==0)
{

    for(i=0;i<brpt;i++) //standart 6 tours
       {
	       if(Buzzer==0){ Buzzer=1; }
	       DelayMS(250);
       }

}
else
{

    for(i=0;i<brpt;i++) //standart 7 tours
       {
	       Buzzer=1;
	       DelayMS(200);
	       Buzzer=0;
	       DelayMS(100);
       }

}

Buzzer=0;

}


countUp(void)
{
	if(countL<9)
	{
		countL++; countX++; getBin();
	}
	else
	{
	     if(countM<7)
	     {
	     	countM++; countL=0; countX++; getBin();
	     }
	}
}

countDown(void)
{
        if(countL!=0)
        {
	        countL--; countX--; getBin();
        }
        else
        {
	        if(countM>0)
	        {
	        countM--; countL=9;  countX--; getBin();
	        }
        }
}


Strt(void)
{


	if(started==0)
	{
                started=1; Output=1;

                EEPROM_WRITE(0, countL);
                EEPROM_WRITE(1, countM);

                beep(0, 6);

                for(i=0;i<countX;i++)
                {
	                for(z=0;z<240;z++) //Wait 1 minute
	                {
		        if(started==0){ break; beep(0, 6); }		        }
	                DelayMs(250);
	                }
	                countDown(); getBin();
                }
                if(countX==0)
                {
	                started, Output=0;
                        beep(1, 7);
	        }

}


Stp(void)
{

	if(started==1)
	{
		started, Output=0;
                beep(0 ,6);
	}
	else
	{
		started, Output, countL, countM, countX=0;
		getBin();
		beep(0, 2);
	}

}



getRotary(void)
{

if(Ri==0&&Ro==0)
{
	rok=1;
}

if(rok==1&&Ri==0&&Ro==1)
{
	countUp(); rok=0;
}
else if(rok==1&&Ri==1&&Ro==0)
{
	countDown(); rok=0;
}

}



main(void)
{
TRISA=0xF0; //Set A ports are input - Buzzer is 0
TRISB=0x00; //Set B ports are output

load();

for(;;)
{


getRotary(); //Rotary Encoder Rotate Detecting

if(Start==0)
{
	 Strt();
}

if(Stp==0)
{
	Stp();
}


}


}


delay.c
#include	"delay.h"

void DelayMs(unsigned char cnt)
{
#if	XTAL_FREQ <= 2MHZ
	do {
		DelayUs(996);
	} while(--cnt);
#endif

#if    XTAL_FREQ > 2MHZ	
	unsigned char	i;
	do {
		i = 4;
		do {
			DelayUs(250);
		} while(--i);
	} while(--cnt);
#endif
}



delay.h
#ifndef	XTAL_FREQ
#define	XTAL_FREQ	4MHZ		/* Crystal frequency in MHz */
#endif

#define	MHZ	*1000			/* number of kHz in a MHz */
#define	KHZ	*1			/* number of kHz in a kHz */

#if	XTAL_FREQ >= 12MHZ

#define	DelayUs(x)	{ unsigned char _dcnt; \
			  _dcnt = (x)*((XTAL_FREQ)/12MHZ); \
			  while(--_dcnt != 0) \
				  continue; }
#else

#define	DelayUs(x)	{ unsigned char _dcnt; \
			  _dcnt = (x)/(12MHZ/(XTAL_FREQ))|1; \
			  while(--_dcnt != 0) \
				  continue; }
#endif

extern void DelayMs(unsigned char);

birkan

DelayMS(250);  yerine
DeyayMs(250); yazın. C dili büyük küçük harf duyarlıdır. "unreachable code" hatası verdiğine göre Kodlarınızda bunun dışında hatalar da olabilir. Zamanım çok kısıtlı kusura bakmayın. Otobüsüm kalkacak. Tatil beni bekliyor.  :lol: