How to eliminate this Link Error????

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

How to eliminate this Link Error????

ソリューションへジャンプ
664件の閲覧回数
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 解決策
484件の閲覧回数
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 返答(返信)
485件の閲覧回数
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 件の賞賛
返信
484件の閲覧回数
vishaka_maithil
Contributor I

Thank you Mac..

0 件の賞賛
返信