Page 1 of 1

Interrupts tips and observations

Posted: Sun Apr 20, 2008 6:23 pm
by RadioT
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

Interrupts/events

Posted: Fri Jul 25, 2008 6:52 pm
by Gordon_h
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

Multiple interrupts

Posted: Tue Jul 29, 2008 12:33 am
by Gordon_h
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

Posted: Sun Aug 03, 2008 3:02 am
by RadioT
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