I have tons of files in this project as I am programming an ARM board. Making a tilt snake game where the snake is controlled by an accelerometer.
I am using a timer interupt (handled by timer0.c) to toggle a boolean variable extern bool toMakeFood;
stored in "includes.h" that tells "main.c" if food should be displayed or not.
The problem I am having is that timer0.c throws a "no definition for toMakeFood" error while main.c has no problem. They both have the line #include "include.h"
Heres the code although I have ommited irrelevant parts as like I said, this is a big(ish) project.
main.c
#include "includes.h"
//more code here, can give you everything if you really want
void makeFood() {
if (toMakeFood == true) {
displayFood(); //not actually implemented, just used to demo this parts use
}
}
timer0.c
#include "includes.h"
//more code here
void Timer0IntrHandler (void)
{
/* clear interrupt */
T0IR_bit.MR0INT = 1;
VICADDRESS = 0;
if (count % 2 == 0) {
toMakeFood = true;
count++;
}
else {
toMakeFood = false;
count++;
}
}
//more code here
includes.h
//loads of includes here
extern bool toMakeFood;
//loads of includes here
main.c has no problem and compiles
timer.0 causes the error shown above
Any ideas as to why?