I am using some code from Jack Ganssles debouce tutorial, and trying to get it to work on an MSP430 using Texas Instruments Code Composer Studio v5.5 (based on Eclipse). I am having an issue with an integer array, that I am using a define value called MAXCHECKS in.
#define MAXCHECKS 8;
int Debounced_state; // Debounced state of the switches
int state[MAXCHECKS]; // Array that maintains bounce status
int Index = 0; // Pointer into state
This line int state[MAXCHECKS]; throws up 2 errors #17 expected "]" and #171 expected a declaration. If I change MAXCHECKS to a value of say 8 or 10 the code builds and loads fine, although it does not debounce the switches, but that is something I can work on as not set the timer up yet.
The code that the define and variables work with is as follows
int i,j;
state[Index] = (P1IN & 0x0088);
++Index;
j = 0xFF;
for(i=0; i<MAXCHECKS; i++)
{
j &= state[i];
}
Debounced_state = j;
if (Index>=MAXCHECKS)
{
Index = 0;
}
I figure it must be something I am missing but at this point unsure hence the question?
Remove the semicolon at the end of the macro definition
#define MAXCHECKS 8;
The pre-processor expands the line in question to
int state[8;];
which causes the compiler error.