Okay so you aren't able to pass a variable into in ISR. This is causing problems for me. I'm using a rotary encoder, and I need it to be connected to an interrupt pin and running a ISR. When using this method, no pulses are ever skipped and the knob works great.
Currently I have the ISR setup like this:
void vhISR()
{
// this checks the PINE register for a 1 or 0 on the 5th bit (or 6th)
// I'm bit shifting the result so that variable is either true or false for comparison, not 16/0 or 32/0
rotCurrentA = (PINE & B00010000) >> 4;
rotB = (PINE & B00100000) >> 5;
if (rotCurrentA != rotLastA)
{
if (rotCurrentA != rotB) // cw
{
voltageHigh += knobResolution;
rotLastA = rotCurrentA;
}
else // ccw
{
voltageHigh -= knobResolution;
rotLastA = rotCurrentA;
}
}
}
The code simply varies voltageHigh by 0.1V increments. The problem is this: I need to do this same 0.1 variations on several other variables, depending on which one I select. I need to increase/decrease a voltageLow, a timer, and a resistance, all that need +/- 0.1 increments (but on different ranges. For instance, voltLow is somewhere between 0.1 & 5, and VH is somewhere between 6 & 10). Normally what I would do is just pass the variable I needed by reference into the function and have the function increment/decrement that variable....but an ISR is not a normal function and you cannot pass a variable into it.
How do I get around this? I'm not sure if that's enough information to go off of let me know.
switch
statement based on a global variable with the current selected setting?