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

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
Has thanked: 6 times
Been thanked: 44 times
Contact:

MX008 - Introduction to interrupts

Postby Sean » Fri May 01, 2009 11:51 am

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.
These users thanked the author Sean for the post:
medelec35 (Tue Nov 02, 2010 10:07 pm)
Rating: 5.26%
 

jose
Flowcode V4 User
Posts: 26
Joined: Sat Nov 01, 2008 12:11 am
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: Introduction to interrupts

Postby jose » Sun May 31, 2009 4:03 pm

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
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Introduction to interrupts

Postby Sean » Mon Jun 01, 2009 3:22 pm

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
Has thanked: 7 times
Been thanked: 10 times
Contact:

Re: Introduction to interrupts

Postby jose » Tue Jun 02, 2009 12:04 am

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

Postby karkamp » Thu Oct 08, 2009 10:11 pm

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
Has thanked: 6 times
Been thanked: 44 times
Contact:

Re: Introduction to interrupts

Postby Sean » Fri Oct 09, 2009 9:21 am

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: 8541
Joined: Sat May 05, 2007 2:27 pm
Location: Northamptonshire, UK
Has thanked: 2456 times
Been thanked: 3526 times
Contact:

Re: Introduction to interrupts

Postby medelec35 » Tue Nov 10, 2009 11:15 am

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!
These users thanked the author medelec35 for the post:
Werner (Wed Nov 16, 2011 12:55 am)
Rating: 5.26%
 
Martin

If you read a post that is useful, please show appreciation by clicking on thumbs up Icon.