In my ISR in user_routines_fast.c I have:
Code:
else if(INTCONbits.RBIF && INCONbits.RBIE)
{
int_byte = PORTB;
INTCONbits.RBIF = 0;
Ultrasonic_Interrupt_Routine(int_byte);
}
That and in my initialize are the only places that I look at the actual register
I tried two things so far, so I am thinking maybe its a problem where I am comparing the 1-0 or 0-1 change on each? Also from what you are saying, there can be multiple changes at once, saying that I should have a different variable for the different sensors because if two of them change, the last port checked will get the data back. Here is what is happening as of now. I have two variables that I have printing back in the ISR. One where it looks for a 1 and one where it looks for a 0.
Code:
if(Triggered_Port & 0x10)
{
if(int_byte & 0x10)
{
//reset the timer;
TMR3H = 0x00;
TMR3L = 0x00;
phasetest++;
}
else
{
//turn off the timer
T3CONbits.TMR3ON = 0;
Ultrasonic_Number=3;
//INTCONbits.RBIE = 0;
}
}
I switched the if and else around and instead of getting 35 and 25 I get a much higher number. I guess that means that it is getting a fairly static time? I also unplugged the sensor while it was running and the values went to 0, so atleast my interrupts are firing somewhat correctly. The two variables move up by 2 at the same time if I have a fairly long delay between my ping() and getdistance() calls.
Thank you very much for your help so far!
Edit: When I changed sensors to make sure it worked my output value changed by about 20, I guess that means that it is timing some set thing about the sensors?