MX008 - Introduction to interrupts

Forum to discuss articles which have been published in Matrix Multimedia's article zone. If you have any comments or questions regarding the articles please post them here.

Moderators: Benj, Mods

Post Reply

Please rate this article out of 5: (1 being the worst and 5 being the best)

1
1
8%
2
0
No votes
3
1
8%
4
3
23%
5
8
62%
 
Total votes: 13

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Contact:

MX008 - Introduction to interrupts

Post by Sean »

Article: http://www.matrixmultimedia.com/article.php?a=55

If you have any questions for the author or comments on the article, please post them below.

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Contact:

Re: Introduction to interrupts

Post by jose »

Hi Sean,
Thanks for your article!
I have a doubt:
Why in the main program the component LED variable is 0 and why in the tmr0isr the component LED variable is 1?
Thanks
Regards
JosΓ©

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Contact:

Re: Introduction to interrupts

Post by Sean »

Hello JosΓ©

The example programs flashes two LEDs to show the difference between the interrupt controlled and the non-interrupt controlled timers.

Both of the LEDs are from the same multi-LED component, LEDs(0).

The first LED, LED(0), is controlled from the main program loop - (LED On(0), LED Off(0))

The second LED, LED(1), is controlled from the timer interrupt service routine - (LED On(1), LED Off(1))

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Contact:

Re: Introduction to interrupts

Post by jose »

Hello Sean,
This was a silly question... sorry
The 0 and 1 are LED position numbers!

Thanks

karkamp
Posts: 3
Joined: Tue Oct 06, 2009 4:47 pm
Contact:

Re: Introduction to interrupts

Post by karkamp »

Hi im having problem to configure a interrupt in a ECIO40P

Could you please tell me if is that possible and how can i do that!?

Thanks

Regreats!

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Contact:

Re: Introduction to interrupts

Post by Sean »

Hello,

Firstly:
Are you testing your interrupt programs on the target hardware, or in simulation?
Are you having problems with a specific interrupt?
Are you writing custom interrupt code?

You should be able to access all of the interrupt sources generated by the PIC18F4455. The ECIO40 is no different to any of the other target devices in this resapect.
Flowcode V3 provides direct support for seven of the more commonly used interrupts (enable, disable, configuration, service routine calls) - Flowcode V4 provides support for additional interrupts. The custom interrupt option provides a Flowcode framework to allow C programmers to gain access to all remaining interrupts not directly supported by Flowcode.

I have downloaded the example programs from this article (written for the PIC16F877A) to an ECIO40 by simply changing the target device in the Chip -> Target menu and compiling to the chip. The TMR0 Overflow interrupt used in the example programs is common to all devices, so the programs run correctly on the ECIO40 when downloaded.

The only change to the operation of the programs is the increased interrupt frequency due to the higher clock speed.

User avatar
medelec35
Valued Contributor
Valued Contributor
Posts: 9015
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Contact:

Re: Introduction to interrupts

Post by medelec35 »

A Tip:
If you want a certain delay or update LCD display after an interrupt has occurred you can do the following:

In the interrupt routine just set a variable eg. called INT_TRIGGER to 1

Then use a decision icon for delay in your main program.
E.g If INT_TRIGGER = 1 then Delay.
Just after delay have INT_TRIGGER = 0
So the delay is not ran until new Interrupt has occurred.

This way the interrupt macro is kept to a minimum, Which should be the ultimate goal!

I found out the hard way you can’t have a delay over a certain value within an interrupt macro.
So best not to have a delay at all!

This may seem obvious to some people, but when you’re first learning the obvious can easily be over looked!
Martin

Post Reply