I have an autoguider that is used for correcting my telescope errors while taking a photograph. It has four active low pins that signal when a correction is required.
Now I have thought of using Pin Change interrupts but the problem I am struggling with remains. Here is the scene.
The guider is connected to PortB pins 5,4,1 and 0.
When no action is required "Anding" a pin mask with PortB will tell me when the pin goes low. So far so good. Now when the guider has detected that enough correction has occurred the pin goes high. I need to detect this change and react to it.
I react by changing the pulse rate on either Timer0 or Timer1 depending on which axis is being corrected.
I am using a Tiny2313 and Assembler.
My thoughts are that I save the condition of the port at the beginning of each scan and then compare the bit to see if it has changed. Looking through the AVR command list I can see commands that compare Registers but not individual bits in that Register.
The simple solution is if the pin is high set the OCRx register for the normal speed. However I am not sure what the effect on the accuracy of the pulse stream would be if the value was being written to on a continuous basis.
If I use Pin Change Interrupts I still have to determine which pin caused the interrupt and whether it had changed from High-to-Low or from Low-to-High.
So I do not know which is best; a tight loop polling the pins or an interrupt. The processor is not doing anything else while the guiding routine is running so I do not have worry about load sharing.