Interrupts tips and observations

Post here if you want to announce new wiki modules, projects or articles

Moderators: David Barker, Jerry Messina

Post Reply
User avatar
RadioT
Registered User
Registered User
Posts: 157
Joined: Tue Nov 27, 2007 12:50 pm
Location: Winnipeg, Canada

Interrupts tips and observations

Post by RadioT » Sun Apr 20, 2008 6:23 pm

Hello,

I added a page in the Articles section of the Wiki on interrupts. Any feed back and edits/corrections would be appreciated.

http://www.sfcompiler.co.uk/wiki/pmwiki ... Interrupts

-Tom

Gordon_h
Posts: 55
Joined: Fri Apr 06, 2007 8:55 pm
Location: Boulder, Colorado

Interrupts/events

Post by Gordon_h » Fri Jul 25, 2008 6:52 pm

Tom,

This is great stuff, I am trying to digest it! An example showing the use of events to handle multiple interrupts would be extremely helpful.

Gordon

Gordon_h
Posts: 55
Joined: Fri Apr 06, 2007 8:55 pm
Location: Boulder, Colorado

Multiple interrupts

Post by Gordon_h » Tue Jul 29, 2008 12:33 am

Tom,

I want to thank you again for organizing this. Using the approach you suggest, I now have three interrupts going simultaneously, all high priority.

Here is the core piece of code- is this how you were suggesting it should be done?

Obviously, the events are in the separate modules.

Module MyInts

Const
ipLow = 1,
ipHigh = 2

Include "MyRx.bas"
Include "MyTimer.bas"
Include "USART.bas"
Include "MyPortB.bas"


Interrupt ISR(ipHigh) ' High Priority ISR code

If (RCIE=1) And (RCIF=1) Then ' USART interrupt code
MyRX.FOnDataEvent()
EndIf

If (Timer1IF=1) And (Timer1IE=1) And (Timer1On=1) Then ' TIMER 1 interrupt code
Timer1 = Timer1 + Word(TimerValue) ' Force integer arithmetic
Dec(TimerCounter)
MyTimer.FOnTimerEvent()
Timer1IF = 0
End If

If (INT0IF=1) And (INT0IE=1) Then ' RB0 interrupt code
MyPortB.FOnInt0Event()
INT0IF=0
End If

End Interrupt

Public Sub Initialize()
MyRX.ActivateRX()
MyTimer.ActivateTimer()
MyPortB.ActivateInt0()
Enable(ISR)
End Sub

User avatar
RadioT
Registered User
Registered User
Posts: 157
Joined: Tue Nov 27, 2007 12:50 pm
Location: Winnipeg, Canada

Post by RadioT » Sun Aug 03, 2008 3:02 am

Yes, basically enable the interrupts you want using conditionals.

It took over a month to get this all sorted out and the code we created was pretty complicated but it works. Unfortunately, some of the code is not mine thus I couldn't post it. It would take a long time to paraphase it for a working example as well, and we are behind schedule in our project as it is.

Since we could "reuse" the two interrupts, we were able to keep using the 18F instead of having to lose 5 months of Swordfish work and move the project to a PIC 24F and a C compiler. We still filled the 96K memory but thankfully were able to move it to a compatible 128K part in the same family.

-Tom

Post Reply