Quote:
|
Originally Posted by Alan Anderson
One more thing occurs to me, and please forgive my nagging about it, but can you double-check to make sure you're not still testing the state of the input pin and deciding whether to increment or decrement the counter? If that code is still there, then you're actually getting counts for the short pulse (because you're always reading it as low by the time you test it), but you're counting one way and then immediately the other way for the long pulses so it doesn't look like you're counting at all.
|
No problem...it is easy to overlook the obvious! I think we're ok, though. For the GTS, the interrupt handler looks like this:
Code:
void Int_3_Handler(unsigned char RB4_State)
{
// this function will be called when an interrupt 3 occurs
LF_Count = LF_Count + 1;
}
So it should just increment on any interrupt, no? For the encoders, it was set up like this:
Code:
void Int_4_Handler(unsigned char RB5_State)
{
// this function will be called when an interrupt 4 occurs
if ((rc_dig_in04 == 0) && (LR_Last_State == 1))
{
if (LR_PHASE_B_PIN == 0)
{
LR_Count = LR_Count - 1;
}
else
{
LR_Count = LR_Count + 1;
}
}
// remember the input state for next time
LR_Last_State = rc_dig_in04;
}