I'm a complete NOOB. I have some programming experience but very little hardware experience.
I have a project that I'm working on and I decided that I would try to implement it with a PIC controller so I purchased the PICKit-1 and started learning.
I plan to use the 16F684 that came with the kit simply because it has enough I/O pins for what I need. I want to use PortA as inputs with interrupt-on-change enabled. Based on what I have learned from the data sheet I have been able to get into my ISR whenever there is a change on one of the input pins. What I haven't been able to discern from the data sheet is how to detect exactly which pin generated the interrupt. My plan is to simply save the port register each time I enter the ISR and compare it to the previously saved setting unless there is a potential problem doing it this way. Or, if there is a better way, I'm certainly open to any suggestions.
One method would be to use a state latch. Basically, after an IOC in your interrupt service routine you exclusive-or the current Port A value with the saved Port A value (the state latch). Resulting '1' bits in W indicate the changed pin or pins.
Code:
;
movf PORTA,W ; read port A
xorwf LATCH,W ; delta current reading & latched reading
xorwf LATCH,F ; update state latch
;