Problem with new release

Coding and general discussion relating to the compiler

Moderators: David Barker, Jerry Messina

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: Problem with new release

Post by Coccoliso » Sun Nov 16, 2014 7:09 pm

Thanks again for the resolution of the problem.
Another question .. the correct mode to use an OnTimer call which is located in an external module is this:

Code: Select all

' ----------- MAIN
Include "health"
...
Timer.Items(Timer1).OnTimer = @Health.Task   // timer event handler
...

Code: Select all

Module Health
...
Public Event Task()
...
End Event

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: Problem with new release

Post by David Barker » Sun Nov 16, 2014 7:17 pm

Yes, that is correct.

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: Problem with new release

Post by Coccoliso » Sun Nov 16, 2014 7:35 pm

David,
test yourself to download it,
look that tells me that the file is corrupt.

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: Problem with new release

Post by David Barker » Sun Nov 16, 2014 7:38 pm

Sorry about that - please try again:

http://www.sfcompiler.co.uk/downloads/beta/

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: Problem with new release

Post by Coccoliso » Sun Nov 16, 2014 7:49 pm

David,
I confirm that recompiled with the INC () instead of the sum the new downloaded version works perfectly.
Now we can go out to eat!

User avatar
Coccoliso
Posts: 152
Joined: Mon Feb 17, 2014 10:34 am

Re: Problem with new release

Post by Coccoliso » Mon Nov 17, 2014 10:34 am

Hello David,
I want to know if it is possible to find a solution to my needs.
As you have seen in the use of the module ISRTimer I was able to use the address of a normal subroutine as the destination of the timer call (and really do not understand as well as even in the help you have specified that the destination MUST BE an event) .
Now this happens .. in the chaos of my sources more than once in the subroutine call destination timer I entered public subroutine of different modules and now I want to know if they are forced to

1) turn into any EVENT SUB called by the timer
2) having to define a new timer for each external subroutine that was previously in the program's main subroutine OnTimer although the timing of the initial timer was 10ms.

from this :

Code: Select all

Private Sub OnTimer()
      Module1.TimerSub()
      Module2.TimerSub()
End Sub
to this:

Code: Select all

Module Module1
    Public Event Timer1Sub()
    ....
    End Event
    ....
End Module

Code: Select all

Module Module2
    Public Event Timer2Sub()
    ....
    End Event
    ....
End Module

Main program

Code: Select all

Const  Timer1 = 0,                           // Timer per flashing Health 
          Timer2 = 1
.... 
    Timer.Initialize(2)

    Timer.Items(Timer1).Interval = 10            // 10ms
    Timer.Items(Timer1).OnTimer = @Module1.Timer1Sub // timer 1 event handler
    Timer.Items(Timer1).Enabled = False

    Timer.Items(Timer2).Interval = 10            // 10ms
    Timer.Items(Timer2).OnTimer = @Module2.Timer2Sub // timer 2 event handler
    Timer.Items(Timer2).Enabled = True


    Timer.Start
    DelayMS(1)
    Timer.Items(Timer1).Enabled = True
I ask because with version 2.2.2.2 subroutine OnTimer () that contained more than a subroutine call different external modules but it was in the module of the main program I had never given any overlap problem.

User avatar
David Barker
Swordfish Developer
Posts: 1214
Joined: Tue Oct 03, 2006 7:01 pm
Location: Saltburn by the Sea, UK
Contact:

Re: Problem with new release

Post by David Barker » Mon Nov 17, 2014 11:06 am

Might be better to start a new thread, as this is not a problem with release. Anyway...

Events should be normally used as callbacks to the main program. It allows users to insert code into an interrupt, without having to actually edit an interrupt. Events have their own stack frame (locals and temps) but they should be treated in the same way as an interrupt. That is, avoid long code, code that calls other subroutines, context saving etc.

Post Reply