How to eliminate this Link Error????

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

How to eliminate this Link Error????

跳至解决方案
615 次查看
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.

标签 (1)
标记 (1)
0 项奖励
1 解答
435 次查看
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 项奖励
2 回复数
436 次查看
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 项奖励
435 次查看
vishaka_maithil
Contributor I

Thank you Mac..

0 项奖励