Tool/software: TI C/C++ Compiler
Hi all,
Do you know how can I put interrupt routine in separate file so it can access global variables form main.c?
For example I've got ADC configuration in separate file as a function:
- main.c:
#include "adc.h"
...
adc_init();
- adc.h:
#ifndef ADC_H_
#define ADC_H_
extern void adc_init(void);
#endif /* ADC_H_ */
- adc.c:
#define extern
#include "adc.h"
#undef extern
#include <msp430.h>
void adc_init(void)
{
ADC12CTL0 |= ADC12ON | ADC12SHT0_3 | ADC12MSC;
...
}
But in main.c I need to have an interrupt routine:
// ADC12 interrupt service routine
#pragma vector=ADC12_VECTOR
__interrupt void ADC12ISR (void)
switch(__even_in_range(ADC12IV, ADC12IV_ADC12RDYIFG))
{
....
case ADC12IV_ADC12IFG1:
Vres -= (unsigned long) Vres_raw[adc_avg_cnt]; //calculate moving averages for ADC inputs
Vres_raw[adc_avg_cnt] = ADC12MEM1;
Vres += (unsigned long) Vres_raw[adc_avg_cnt];
break;
....
}
and I would love to put this routine into adc.c file