PDA

View Full Version : interrupt register



l_gaminde
- 26th February 2013, 16:36
I have a serial process that needs to finish its cycle before moving on. I will be using a pushbutton to advance to the next step, my plan was to use portb.0 interrupt pin for this by setting the interrupt bit ( intsomething ) and then polling this bit when the serial data has completed. Is this a logical approach.

HenrikOlsson
- 26th February 2013, 17:55
Hi,
Sure, that'll work. The interrupt request bit will get set even if the interrupt is masked (so it won't actually trip an interrupt) so you can poll the flag. Don't forget to reset it or you will most likely lock up.

/Henrik.

l_gaminde
- 26th February 2013, 19:26
Henrik thanks so the interrupt will not jump to the set line number if I just turn on portb.0 interrupt thats good and then polling the interrupt flag bit will work like a latch for me thats good.

Ok will try and by the way Im just getting back into PBP so lock up is my middle name

HenrikOlsson
- 26th February 2013, 19:54
Hi,
No, the whole idea is to NOT turn the interrupt on, in other words don't enable it. If you enable it (and the GIE bit is set) it WILL cause interrupt - which you don't want.
It doesn't matter if the interrupt is enabled or disabled, the interrups request flag will get set no matter what. It's just that it won't cause an actual interrupt when it's not enabled. Depending on which PIC it is you may want to set if you want the flag to be set on the rising or falling edge, which PIC is it?

And you're right, it'll work as a nice latch.

/Henrik.

l_gaminde
- 26th February 2013, 20:06
16f648a if that's the case will any port b pin set the register bit

HenrikOlsson
- 26th February 2013, 20:22
No, PortB.0 is the INT0 pin, it will set INTF-bit (INTCON.1)
PortB.4-7 has interrupt on change, a mismatch condition will set the RBIF-bit (INTCON.0)
PortB.1-3 does not have any interrupt capabillity on the 16F648.

/Henrik.

l_gaminde
- 26th February 2013, 20:29
okay so by not setting any port those 2 flags are always turning on intcon.1 and intcon.0 right now I am actually using portb.0 for LCD out so I may just try the 4 through 7 which are unused pins.

HenrikOlsson
- 26th February 2013, 20:49
I'm afraid I don't follow you on that last one....not setting any port?
I'd move the LCD to other pins in order to free up PortB.0 for your "polled interrupt".
PortB.4-7 are, like I said, interrupt on change - they will set the interrupt flag (INTCON.0) on both the rising AND falling edge and you need to read or write the port to end the mismatch, then clear the flag. They are trickier to use the INT0.

l_gaminde
- 26th February 2013, 21:09
guess Im confused! so turn nothing on and the flag will set with a high or low on portb.0 it is always active even while in digital mode I will see the flag bit set if checked.

l_gaminde
- 27th February 2013, 02:04
OK it does work skips two sometimes will work on it tomorrow. One little thing don't spend an hour working on this because you forgot to change port pin to input it does not work that way.

Henrik thanks for all your help