How to eliminate this Link Error????

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to eliminate this Link Error????

Jump to solution
544 Views
vishaka_maithil
Contributor I

Dear friends,

 

 I am using CW V5.0 for 16bit controller programming. In my program, I am using SCI, ADC and other modules.Through SCI receive interrupt, I set ADC control register bits for resolution.  SCI ISR is in main.c and I declared a global variable for this resolution in main.c. My ADC initialization is done in another .c file  for which initialization header file is included in main.c When I make, there gives me a link error for ADC resolution.For clear understanding,

 

#include <hidef.h>

#include "derivative.h"

#include "adc.h"

unsigned int adc_resolution;

void main(void)

{

SCI();

------

EnableInterrupts;

adc();

----

for(;:smileywink:;

}

SCI_ISR()

{

adc_resolution = SCI0DRL;

}

/********************end of main.c*******************/

#ifndef adc_h

#define adc_h

void adc(void);

void sci(void);

#endif

/******************end of adc.h*********************/

#include "derivative.h"

void adc(void)

{

------

ATD0CTL1=adc_resolution;

----

---

}

void sci(void)

{

---

}

/***********************end of adc.c*********************/

 

Need help...

Thank you in advance.

Labels (1)
Tags (1)
0 Kudos
1 Solution
364 Views
bigmac
Specialist III

Hello Visu,

 

The definition of the global variable is within main.c.  Therefore the file adc.c will require a declaration of the variable, either diredtly within the file, or within a header file that is included within adc.c.  This must occur prior to the variable being used within the file.

 

extern unsigned int adc_resolution;

 

 

Regards,

Mac

 

View solution in original post

0 Kudos
2 Replies
365 Views
bigmac
Specialist III

Hello Visu,

 

The definition of the global variable is within main.c.  Therefore the file adc.c will require a declaration of the variable, either diredtly within the file, or within a header file that is included within adc.c.  This must occur prior to the variable being used within the file.

 

extern unsigned int adc_resolution;

 

 

Regards,

Mac

 

0 Kudos
364 Views
vishaka_maithil
Contributor I

Thank you Mac..

0 Kudos