PDA

View Full Version : Priority interrupt?



Qacer
- 5th October 2006, 21:36
Hi all,

:)

I have three signals that are prioritized. Let's say S1 = 1st priority, S2 = 2nd, and S3 = 3rd.

I'm planning on connecting each signal line to an available pin in the PIC mcu. I'm trying to understand how I can use the interrupt feature so that it will do the following:

- if S1 is present, then ignore any signals from S2 and S3 and output S1.
- if S2 is present and S1 is not, then ignore any signal from S3 and output S2.
- however, if S1 comes on a few seconds later, then ignore S2 and S3 and output S1.

Can anyone give me some tips on how I can go about implementing this?

I haven't really dealt with the interrupt feature before.

Thanks!

DynamoBen
- 5th October 2006, 22:27
Interrupts are what they say they are, the are actions that interrupt the normal progression of your software.

For example, when serial data comes into the UART and interrupt occurs and the program jumps to a sub to collect the data. Once complete the program continues where it was interrupted.

What you are describing is a bunch of conditional statements, not really interrupts.

Qacer
- 5th October 2006, 22:56
Hi! :)

You are correct. They are conditional statements, but I'm trying to figure out how to do this (sorry if I don't explain it clearly.. I'm still thinking it in my head):

- If S2 is present, then output the signal at the same time perform some instructions specific to S2. So while these instructions are being performed, if S1 comes on, then I want to be able to interrupt this process and perform the instructions specific to S1.

- But if S1 is present and S1 specific instructions are carried out, I don't want S2 to interrupt this process.

- However, since S2 has a higher priority than S3, it then has to have some interrupt capability to break any S3 instructions that are currently performed.

So that means that while S1 instructions are being processed, a signal from S2 can still interrupt S1.

How do I keep lower priority signals from interrupting higher priority signals? (I guess this should've been my original question.)

Thanks! :)

DynamoBen
- 5th October 2006, 22:59
To give you any more assistance we will need more information.
What you are explaining is way too vague and ethereal to give an accurate answer.

What specifically are you trying to do? What are these “signals” you are trying to receive? What are you trying to output? What type of chip are you using? What ports are these “signals” connected to?

Qacer
- 6th October 2006, 03:44
Hiya!

Well, let's say the signals are a sample of an analog signal rectified and sent to a multivibrator to turn them into a pulse representation. The pulses are then sent to a pin to a PIC. I don't have any specific chips in mind, but I'm thinking maybe a PIC12F675.

The signals come from multiple sources. Let's say three. So, I would use three pins from the PIC. Then, when the PIC detects a signal, it is supposed to do some processing and then re-route the signal via a separate analog switch. The PIC would control the analog switch.

So as different signals come along from different sources, then the PIC is supposed to prioritized them based on which source the signal comes from. So, if the PIC is processing a signal from a 2nd priority source and a 1st priority signal comes along, it is supposed to stop what its doing and process the 1st priority signal.

DynamoBen
- 6th October 2006, 04:06
Interrupts are determined by the pic you choose.

The only interrupt that might apply, depending on the pic, is PortB change. Even then all it would do is jump to a sub anytime one of the affected ports changed status. You still would need to write code to determine the "priorities" you are speaking of.

Based on the application interrupts are not going to be any assistance to you. You are going to have to do this conventionally by polling each pin and writing conditional statements. Interrupts don't function in the way you are hoping they would.

I would assume this if for the following project http://www.picbasic.co.uk/forum/showthread.php?t=4772

Qacer
- 6th October 2006, 16:47
Hello, :)

Yep, it is for that project. I thought about polling the pins, but that would take extra battery charge, which I really don't want to do.

Thanks!