PDA

View Full Version : 16f877 port configuration & interrupts



Rob Martin
- 15th April 2005, 09:20
For those who already ready this posting I had a duff pic!
But I still have an Interrupt question

My problem is I want to run a piece of code everytime RA1 < RA4 change status. Am I right in understanding that I can assign these all to one interrupt?
Also when the interrupt happens will it stop it's current instruction? e.g. if I'm haveway through reading an rs232 input will it breakout or wait till it completed it's read?

Is there a definitive idiots guide to interrupts and making sense of the datasheets for those of us who are learning?


Rob

Melanie
- 15th April 2005, 13:20
1. You're out of luck if you want to use PortA for interrupt on pin change. Usually it's PortB (certainly on the 16F series, not sure on all the 18F) but your PICs Datasheet will tell you what triggers interrupts and what doesn't.

2. PICBasic disables interrupts so that the current command completes execution before you get passed to your interrupt routine. There will be no problems if you use PICBasics interrupts. If you use Assembler interrupts then that's another story... PICBasic will be interfered with, commands such as DEBUG, SERIN, SEROUT etc will lose timing and you will lose Data, or in the least have it corrupted. If you're going to have Assembler interrupts then you really need to use the USART on the PIC and handle that externally from PICBasic as well.

The Datasheet is the best and only informative document as to what you can and can't do with any PIC. Sorry there's no magic book or substitute - so make friends with it, save yourself the money and buy yourself a crate or two of beer (which also helps in the learning process).

Rob Martin
- 15th April 2005, 17:30
I have a two beer fridges which probably wont help unless I can bribe someone to come round and teach me for beer ;)

I did download the data sheet and the interrupts sit on the RB pins as you thought. Having never used interrupts in my life I'm doing the time honoured way of trying to find some code that works as an example then break and see why it works. I'm not looking for a free ride I just need to get my head around how they work.
From what you say If i need to act on three seperate pins I'll need to have three seperate interrupts on the three pins.

Makes sense I just need to read and ask more questions :)

Rob