PDA

Visualizza la versione completa : [c] errore di overlay


biancag
24-02-2005, 16:31
Ciao a tutti,
sto programmando un microcontrollore in C usando MPLAB IDE ed in fase di compilazione mi da il seguente errore:

MPLINK 3.90, Linker
Copyright (c) 2004 Microchip Technology Inc.
Error - section '_entry_scn' type is non-overlay and absolute but occurs in more than one input file.
Errors : 1

che significa?
forse un problema di stack insufficiente?
Il mio programma ha 10 function e qualche volta una richiama un'altra. :dh:

anx721
24-02-2005, 19:38
non capisco l'errore, anche perche presumo che usi un compilatore diverso dal mio, ma senza il codice e nu po difficile risponderti

biancag
25-02-2005, 12:28
penso di fare troppe chiamate a funzioni annidate.
Comunque questo il codice e .....grazie anticipatamente


#include<p18f1220.h>

typedef unsigned char BYTE;
typedef unsigned short WORD;
typedef BYTE * pBYTE;
typedef WORD * pWORD;


#define OR ||
#define AND &&

/************************************************** ***********************************/
/* #define vari... */
/************************************************** ***********************************/
#define LED_RED_ON PORTBbits.RB5=1
#define LED_RED_OFF PORTBbits.RB5=0
#define LED_GREEN_ON PORTBbits.RB3=1
#define LED_GREEN_OFF PORTBbits.RB3=0
#define START_ADC ADCON0bits.GO=1
#define ADC_ON ADCON0bits.ADON=1
#define ADC_OFF ADCON0bits.ADON=0
#define G_LIM_ON PORTAbits.RA6=1
#define G_LIM_OFF PORTAbits.RA6=0
#define C_LIM_ON PORTAbits.RA7=1
#define C_LIM_OFF PORTAbits.RA7=0
#define S_LIM_ON PORTAbits.RA4=1
#define S_LIM_OFF PORTAbits.RA4=0
#define DRV_OK PORTBbits.RB5=0
#define DRV_OFF PORTBbits.RB5=1
#define FINAL_ST_ON PORTBbits.RB3=1
#define FINAL_ST_OFF PORTBbits.RB3=0
#define MIRR_ALL_ON PORTBbits.RB7=1
#define MIRR_ALL_OFF PORTBbits.RB7=0
#define DRV_EN_ON PORTBbits.RB6=0
#define DRV_EN_OFF PORTBbits.RB6=1
#define POS_LEV_H 1000
#define POS_LEV_L 100
#define AGC_LEV_H 1000
#define AGC_LEV_L 100
#define TEMP_LEV_I 90
#define TEMP_LEV_II 100
#define TEMP_LEV_III 110
#define ERR_LIM 100
#define HFD_LEV_H 1000
#define HFD_LEV_L 100
#define PWR_UP 1000
#define PWR_LOW 100


BYTE InitPorteAN(void);
BYTE InitPorteA(void);
BYTE InitPorteB(void);
BYTE InitClock8M(void);
BYTE DriverDisabled(void);
WORD FirstInCheck(void);
WORD ReadADChannel(BYTE);
WORD DriverEnabled(void);
WORD OverPosition (void);

WORD Timer, check, true, false, state, AGC, HFD, Mirr, DRVEn, temp;

void main (void)
{
InitPorteAN();
InitPorteA();
InitPorteB();
InitClock8M();

LED_GREEN_OFF;
LED_RED_OFF;
DriverDisabled();

while (1)
{
check=FirstInCheck();
if (check=false) DriverDisabled(); /* Controllo iniziale driver */
else
{
check=DriverEnabled();
if (check=false) DriverDisabled(); /* Abilitazione driver */
else
{
check=true;
while (check=true)
{
switch (state)
{

case 0: /* Controllo di Over-position */
check=OverPosition();
if (check=false)
{
DriverDisabled();
break;
}

case 1: /* Controllo AGC */
AGC=ReadADChannel(4);
if ((AGC<AGC_LEV_L) OR (AGC>AGC_LEV_H))
{
check=false;
DriverDisabled();
break;
}

case 2: /* Controllo di errore d'inseguimento */
if (ReadADChannel(2)>ERR_LIM) LED_RED_ON;

case 3: /* Controllo saturazione integrazione HFD */
HFD=ReadADChannel(3);
if ((HFD<HFD_LEV_L) OR (HFD>HFD_LEV_H))
{
check=false;
DriverDisabled();
break;
}

case 4: /* Controllo +PWR */
if (ReadADChannel(5)>PWR_UP)
{
check=false;
DriverDisabled();
break;
}

case 5: /* Controllo -PWR */
if (ReadADChannel(6)<PWR_LOW)
{
check=false;
DriverDisabled();
break;
}

case 6: /* Controllo di Mirror Allignement */
if (Mirr = MIRR_ALL_OFF)
{
C_LIM_OFF;
S_LIM_OFF;
while (Mirr = MIRR_ALL_OFF) {/* Do Nothing */};
S_LIM_ON;
Timer=0;
while (Timer<2000) Timer++; /* attesa 20 ms */
C_LIM_ON;
}

case 7: /* Condizione di driver disabilitato */
if (DRVEn=DRV_EN_OFF)
{
check=false;
DriverDisabled();
break;
}

case 8: /* Controllo della corrente di bobina */
temp=ReadADChannel(0);
if (temp>=TEMP_LEV_I)
{
LED_RED_ON;
if (temp>=TEMP_LEV_II)
{
C_LIM_OFF;
if (temp>=TEMP_LEV_III)
{
check=false;
DriverDisabled();
break;
}
}
}
}
}
}
}
}
}




/************************************************** ***********************************/
/* InitClock8M Inizializza l'oscillatore interno a funzionare a 8MHz */
/************************************************** ***********************************/

BYTE InitClock8M(void)
{
OSCCONbits.SCS0=0;
OSCCONbits.SCS1=1;
OSCCONbits.FLTS=1;
OSCCONbits.OSTS=1;
OSCCONbits.IRCF0=1;
OSCCONbits.IRCF1=1;
OSCCONbits.IRCF2=1;
OSCCONbits.IDLEN=0;
return 0;
}


/************************************************** ***********************************/
/* InitPorte Inizializza le porte */
/************************************************** ***********************************/

BYTE InitPorteAN(void) /* configure Analog Input */
{
ADCON0 = 0b00000000; /* usa il Vref interno e legge dalla porta RA0, spenge l'AD */
ADCON1 = 0b01100000;
ADCON2 = 0b10111001; /* giustifica a dx, 20 Tacq, Fosc/8*/
return 0;
}

BYTE InitPorteA(void) /* configure PORTA for input/output */
{
TRISAbits.TRISA0=1;
TRISAbits.TRISA1=1;
TRISAbits.TRISA2=1;
TRISAbits.TRISA3=1;
TRISAbits.TRISA4=0;
TRISAbits.TRISA5=1;
TRISAbits.TRISA6=0;
TRISAbits.TRISA7=0;
return 0;
}

BYTE InitPorteB(void) /* configure PORTB for input/output */
{
TRISBbits.TRISB0=1;
TRISBbits.TRISB1=1;
TRISBbits.TRISB2=0;
TRISBbits.TRISB3=0;
TRISBbits.TRISB4=1;
TRISBbits.TRISB5=0;
TRISBbits.TRISB6=1;
TRISBbits.TRISB7=1;
return 0;
}


/************************************************** ****************************/
/* Funzione che legge il canale passato, lo campiona 2 volte, ne fa la */
/* media e ritorna il valore a 10 bit */
/************************************************** ****************************/

WORD ReadADChannel (BYTE Channel)

{
WORD Value1,Value2,Result;

ADC_OFF;
switch (Channel)
{
case 0:
TRISAbits.TRISA0=1;
ADCON0 = 0b00000000; /* set AN0 (Corrente di bobina) */
break;

case 1:
TRISAbits.TRISA1=1;
ADCON0 = 0b00000100; /* set AN1 (Posizione) */
break;

case 2:
TRISAbits.TRISA2=1;
ADCON0 = 0b00001000; /* set AN2 (Errore d'inseguimento) */
break;

case 3:
TRISAbits.TRISA3=1;
ADCON0 = 0b00001100; /* set AN3 (Integratore HFD) */
break;

case 4:
TRISBbits.TRISB0=1;
ADCON0 = 0b00010000; /* set AN4 (AGC) */
break;

case 5:
TRISBbits.TRISB1=1;
ADCON0 = 0b00010100; /* set AN5 (+ PWR) */
break;

case 6:
TRISBbits.TRISB4=1;
ADCON0 = 0b00011000; /* set AN6 (- PWR) */
break;

default:
break;
}

ADC_ON;

/* Prima lettura */
START_ADC;
while (ADCON0bits.GO) {/* Do Nothing */};
Value1=ADRESH;
Value1=Value1<<8;
Value1+=ADRESL;


/* Seconda lettura */
START_ADC;
while (ADCON0bits.GO) {/* Do Nothing */};
Value2=ADRESH;
Value2=Value2<<8;
Value2+=ADRESL;

ADC_OFF; /* Rispengo l'ADC */

Result=(Value1+Value2)>>1; /* Faccio la media */
Result=MIN(1023,Result);

return Result;

}

/************************************************** ****************************/
/* Funzione che disabilita il driver */
/************************************************** ****************************/


BYTE DriverDisabled (void)
{
G_LIM_OFF;
C_LIM_OFF;
S_LIM_OFF;
FINAL_ST_OFF;
Timer=0;
while (Timer<5000) Timer++; /* attesa 50 ms */
return 0;
}

/************************************************** ****************************/
/* Funzione che effettua il primo check sui canali in input */
/************************************************** ****************************/

WORD FirstInCheck (void)
{
WORD Out, Pos, I2, Err, PPWR, MPWR;

Out=true;
Pos=ReadADChannel(1);
if ((Pos<POS_LEV_L) OR (Pos>POS_LEV_H)) Out=false;
else
{
AGC=ReadADChannel(4);
if ((AGC<AGC_LEV_L) OR (AGC<AGC_LEV_H)) Out=false;
else
{
I2=ReadADChannel(0);
if (I2>TEMP_LEV_I) Out=false;
else
{
Err=ReadADChannel(2);
if (Err>ERR_LIM) Out=false;
else
{
HFD=ReadADChannel(3);
if ((HFD<HFD_LEV_L) OR (HFD<HFD_LEV_H)) Out=false;
else
{
PPWR=ReadADChannel(5);
if (PPWR>PWR_UP) Out=false;
else
{
MPWR=ReadADChannel(6);
if (MPWR<PWR_LOW) Out=false;
else if (Mirr = MIRR_ALL_OFF) Out=false;
else if (DRVEn=DRV_EN_OFF) Out=false;
}
}
}
}
}
}
return Out;
}

/************************************************** ****************************/
/* Funzione che abilita il driver */
/************************************************** ****************************/

WORD DriverEnabled (void)

{

WORD en_driver;

FINAL_ST_ON;
Timer=0;
while (Timer<10000) Timer++; /* attesa 100 ms */
check=FirstInCheck();
if (check=false) en_driver=false;
else
{
S_LIM_ON;
Timer=0;
while (Timer<10000) Timer++; /* attesa 100 ms */
check=FirstInCheck();
if (check=false) en_driver=false;
else
{
G_LIM_ON;
Timer=0;
while (Timer<10000) Timer++; /* attesa 100 ms */
check=FirstInCheck();
if (check=false) en_driver=false;
else
{
C_LIM_ON;
Timer=0;
while (Timer<10000) Timer++; /* attesa 100 ms */
check=FirstInCheck();
if (check=false) en_driver=false;
else
{
DRV_OK;
en_driver=true;
}
}
}
}
return en_driver;
}

/************************************************** ****************************/
/* Funzione che rivela un fault di over position */
/************************************************** ****************************/

WORD OverPosition (void)

{

WORD OverPos, Pos;

Pos=ReadADChannel(1);
if ((Pos<POS_LEV_L) OR (Pos>POS_LEV_H))
{
C_LIM_OFF;
Timer=0;
while (Timer<2000) Timer++; /* attesa 20 ms */
Pos=ReadADChannel(1);
if ((Pos<POS_LEV_L) OR (Pos>POS_LEV_H))
{
LED_RED_ON;
OverPos=false;
}
else OverPos=true;
}
else OverPos=true;
return OverPos;
}



impaginato meglio forse si capirebbe un po'. :dh:

unomichisiada
25-02-2005, 13:11
impaginato meglio forse si capirebbe un po'. :dh:
Allora la prossima volta usa i tag CODE...

anx721
25-02-2005, 16:28
#include<p18f1220.h>

p18f1220.h non un header standarda, da dove viene? La prossima volta indenta il codice e posta solo le righe in cui il compilatore d l'errore.

netarrow
25-02-2005, 16:40
guarda se questo ti utile: http://forum.microchip.com/tm.asp?m=42176

:ciauz:

biancag
25-02-2005, 18:43
grazie, ho risolto il problema!
Dovevo soltanto eliminare il file C018i.o dal mio progetto. :ciauz:

Loading