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();
----
}
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.
已解决! 转到解答。
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
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