For some time I have been wondering what people do in most instances if they need a button to perform an action. I thought most people would use an interrupt on change (available on all PORTB pins of the PICs I usually use) to enter the interrupt routine and do what they need to do.
But after reading some and looking at examples 2 things came to mind.
-Most examples I see just use some sort of 'if' statement such that if a pin is tied pulled high (switch closed) then perform this action. Do me this doesn't make sense for long codes and seems prone to missing or double counting. Do many people use this method?
-Then I thought if using interrupt on change is more reliable, how do you get whatever you modified back from the interrupt? If the button is to change a setting (not just the state of a pin) how does this get returned back to the main function?
I use the mikroelectronica EasyPIC6 development board and 6 of the 8 PORTB pins are dedicated for LCD (when enabled) so it seems like these are not too desirable. I program in C.
Thanks!
But after reading some and looking at examples 2 things came to mind.
-Most examples I see just use some sort of 'if' statement such that if a pin is tied pulled high (switch closed) then perform this action. Do me this doesn't make sense for long codes and seems prone to missing or double counting. Do many people use this method?
-Then I thought if using interrupt on change is more reliable, how do you get whatever you modified back from the interrupt? If the button is to change a setting (not just the state of a pin) how does this get returned back to the main function?
I use the mikroelectronica EasyPIC6 development board and 6 of the 8 PORTB pins are dedicated for LCD (when enabled) so it seems like these are not too desirable. I program in C.
Thanks!