When program execution exits a function, the memory assigned to the variables that are local to that function is freed for use by other parts of the function. This means that the values of the local variables will not be the same the next time the function is called. In cases where you want the values of variables to persist between function calls, the static declaration is used before the variable type in the variable definition. In the example in the first section, the debounce counter buttonDownCounter is used to as a counter whose value needs to be maintained across function calls, and is therefore declared to be static.
void checkButton(void) {
static u16 buttonDownCounter;
...
}