Hello all,
On a PIC16F627A:
Looking for some advice on how to simultaneously handle an external interrupt on RB0 as well as a timer. I am kind of new to this whole interrupt thing, and from my research I have no idea how to differentiate between which interrupt has triggered.
From what I know thus far:
External Interrupt on RB0:
-Set INTCON = %10010000
-have line of code "On interrupt goto myint"
-end myint with resume
-wrap myint with command disable and enable (to disable/enable any other interrutps)
I believe once you do this, when RB0 goes high it will execute code in myint - correct?
And now for the timer0 (will likely need a 10 second timer) -
To set up (using 4MHz):
-Prescaler should be 1 so "0b000" (longest time between ticks)
-Start TMR0 at 0h00
-Need to set appropiate enable flag in INTCON
So now here's where I am confused:
A) How do I find out how many ticks I need for approximately 10 seconds?
B) How do I know what will happen when timer overflows? Will nothing happen - in this case I need to poll the timer flag and when it overflows then take appropriate action?
C) If an external interrupt occurs, it will execute instructions with interrupts disabled, does this mean the timer will halt? Anything need to be done to start it up again?
D) Kind of related to (C), what needs to be done each time the timer overflows to restart the event? Reset TMR0 to 0h00 and clear the flag in INTCON?
Thanks for any and all help!
Bookmarks