This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Redifinition Error

Dear all,

I have compiled the following program and am getting redifinition error. I have not redifined the function anywhere, Please help.

Following is my code:

// SFR description needs to be included
#include <reg932.h>
#include "timer.h"
#include "eeprom.h"
#include "port.h"

// flag that indicates if the EEPROM is busy or not
//static bit meeprombusy;
//bit bdata flags;
//s/bit combit = flags^0;
//extern bdata int combit flags;
//****************************
//** Main Program ** //
//****************************
void main(void)
{
interrupt_enable();

ports_init();
eeprom_init();
// flag that indicates if the EEPROM is busy or not

eeprom_initread();
if(DEEDAT =! 0)
timers_init();
else
eeprom_readloc1();
eeprom_readloc2();
eeprom_readloc3();
eeprom_readloc4();
loadvalues


timers_starttimer0();
timers_stoptimer0();

}
/**************************
DESC: Initializes timers
Timer 0 generates an interrupt every 1s
Timer 1 is not used
RETURNS: Nothing
CAUTION: If interrupts are being used then EA must be set to 1
after calling this function
************************************************************************/
void timers_init (void)
{
// configure timer 0
TMOD &= 0xF0;
TMOD |= 0x01;
TAMOD &= 0xFE;

// timer values
TH0 = 0xff;
TL0 = 0xfe;

// set timer 0 isr priority to 0
IP0 &= 0xFD;
IP0H &= 0xFD;

// enable timer 0 interrupt
EA = 1;
ET0 = 1;

// start timer 0
TR0 = 1;

} // timers_init

/**************************
DESC: Timer 0 Interrupt Service Routine
RETURNS: Nothing
CAUTION: timers_init must be called first
EA must be set to 1
***************************/
void timers_isr0(void) interrupt 1 using 1
{
// reinitialize
TH0 = 0xC0;
TL0 = 0x00;

}
/**************************
DESC: Starts timer 0
RETURNS: Nothing
CAUTION: timers_init must be called first
***************************/
void timers_starttimer0(void)
{
TR0 = 1;
} // timers_starttimer0

/**************************
DESC: Stops timer 0
RETURNS: Nothing
CAUTION: timers_init must be called first
***************************/
void timers_stoptimer0 ( void )
{
TR0 = 0;
} // timers_stoptimer0

/**************************
DESC: Initializes the EEPROM. Enables EEPROM interrupt
RETURNS: Nothing
CAUTION: Set EA to 1 after calling to enable all interrupts
/***************************/
void eeprom_init
(
void
)
{
// initially eeprom is not busy
meeprombusy = 0;

// set isr priority to 0
IP1 &= 0x7F;
IP1H &= 0x7F;
// enable eeprom interrupt
EIEE = 0;
}

/**************************
unsigned char eeprom_initread
(
unsigned int address // 9-bit address to read (0x000 - 0x1FF)
)
{
// wait for previous operation to complete
while (meeprombusy);

// eeprom now busy
meeprombusy = 1;

// store bit 8 of address
// byte operation, clear interrupt flag
DEECON = (address >> 8) & 0x01;
// store bits 0-7 of address
DEEADR = address & 0xFF;

// if not using interrupt then poll for end of operation
if (!EA || !EIEE)
{
// wait for operation to complete
while (!(DEECON & 0x80));
// eeprom no longer busy
meeprombusy = 0;
// return value
return DEEDAT;
}

return 0x00;
}
/**************************/

unsigned char eeprom_readloc1
(
unsigned int address // 9-bit address to read (0x000 - 0x1FF)
)
{
// wait for previous operation to complete
while (meeprombusy);

// eeprom now busy
meeprombusy = 1;

// store bit 8 of address
// byte operation, clear interrupt flag
DEECON = (address >> 8) & 0x01;
// store bits 0-7 of address
DEEADR = address & 0xFF;

// if not using interrupt then poll for end of operation
if (!EA || !EIEE)
{
// wait for operation to complete
while (!(DEECON & 0x80));
// eeprom no longer busy
meeprombusy = 0;
// return value
return DEEDAT;
}

return 0x00;
}

/**************************/
void interrupt_enable (void)

{

EA =1;
EX0 =1;
ET0 =1;

}

/**************************
void ports_init
(
void
)

{
P0M1 &= 0xFE;
P0M2 &= 0xFE;

P1M1 |= 0x28;
P1M2 &= 0xD7;

P3M1 |= 0x03;
P3M2 &= 0xFC;
} // ports initialisation

Parents
  • Following is my code:

    // SFR description needs to be included
    #include <reg932.h>
    #include "timer.h"
    #include "eeprom.h"
    #include "port.h"
    

    What's in all these .h files ?

    // flag that indicates if the EEPROM is busy or not
    //static bit meeprombusy;
    //bit bdata flags;
    //s/bit combit = flags^0;
    //extern bdata int combit flags;
    //****************************
    //** Main Program ** //
    //****************************
    void main(void)
    {
    interrupt_enable();
    

    Ok. I did not see a prototype for this function. Is it in one of those .h files or is it simply missing ? If this is the first time the compiler sees interrupt_enable();, it will think that it is a function definition.

    ports_init();
    eeprom_init();
    // flag that indicates if the EEPROM is busy or not
    
    eeprom_initread();
    if(DEEDAT =! 0)
    timers_init();
    else
    eeprom_readloc1();
    eeprom_readloc2();
    eeprom_readloc3();
    eeprom_readloc4();
    

    Ok. What _should_ this code do ? It looks like it should call timers_init(); if DEEDAT is not equal to zero, else call eeprom_readloc1();, eeprom_readloc2();, eeprom_readloc3(); and eeprom_readloc4();. Right now, it's probably going to give you a syntax error ("=!" instead of "!="), and then, it is going to call timers_init(); if DEEDAT is not equal to zero, else call eeprom_readloc1(); and then always call eeprom_readloc2();, eeprom_readloc3(); and eeprom_readloc4();. Also, where are the prototypes for all these functions ? The compiler sees them for the first time and will assume they are implied function definitions.

    loadvalues
    

    All this does is give you some kind of syntax error. Did you mean loadvalues(); ?

    timers_starttimer0();
    timers_stoptimer0();
    }
    

    More functions without prototypes.

Reply
  • Following is my code:

    // SFR description needs to be included
    #include <reg932.h>
    #include "timer.h"
    #include "eeprom.h"
    #include "port.h"
    

    What's in all these .h files ?

    // flag that indicates if the EEPROM is busy or not
    //static bit meeprombusy;
    //bit bdata flags;
    //s/bit combit = flags^0;
    //extern bdata int combit flags;
    //****************************
    //** Main Program ** //
    //****************************
    void main(void)
    {
    interrupt_enable();
    

    Ok. I did not see a prototype for this function. Is it in one of those .h files or is it simply missing ? If this is the first time the compiler sees interrupt_enable();, it will think that it is a function definition.

    ports_init();
    eeprom_init();
    // flag that indicates if the EEPROM is busy or not
    
    eeprom_initread();
    if(DEEDAT =! 0)
    timers_init();
    else
    eeprom_readloc1();
    eeprom_readloc2();
    eeprom_readloc3();
    eeprom_readloc4();
    

    Ok. What _should_ this code do ? It looks like it should call timers_init(); if DEEDAT is not equal to zero, else call eeprom_readloc1();, eeprom_readloc2();, eeprom_readloc3(); and eeprom_readloc4();. Right now, it's probably going to give you a syntax error ("=!" instead of "!="), and then, it is going to call timers_init(); if DEEDAT is not equal to zero, else call eeprom_readloc1(); and then always call eeprom_readloc2();, eeprom_readloc3(); and eeprom_readloc4();. Also, where are the prototypes for all these functions ? The compiler sees them for the first time and will assume they are implied function definitions.

    loadvalues
    

    All this does is give you some kind of syntax error. Did you mean loadvalues(); ?

    timers_starttimer0();
    timers_stoptimer0();
    }
    

    More functions without prototypes.

Children
No data