@Bean, TASKS RUN proposal
@Bean,
To use TASKS RUN, the following setup is required:
TASKS RUN must be given prior to TASKS SET or there are compilation errors.
I'd like to jump to the interrupt code leaving the largest amount of space for the SUB jumptable.
Unfortunately, I cannot place TASKS RUN at IsrStart.
My proposal is to leave TASKS RUN at the current position (after INTERRUPT keyword),
but to place the code generated by TASKS RUN, when RETURNINT is encountered.
That saves valuable codespace for the SUB jumptable (which also holds entries for TASK routines).
I don't see any problems it would give for the code, other than that you must suspend
some output to the .SRC file until RETURNINT is encountered.
regards peter
Post Edited (Peter Verkaik) : 7/18/2009 10:04:22 AM GMT
To use TASKS RUN, the following setup is required:
'************************************************************************************************* 'Device Settings '************************************************************************************************* device SX28,OSCHS2 freq 20_000_000 id "TaskTest" stack 16 '************************************************************************************************* 'CON Section '************************************************************************************************* '************************************************************************************************* 'I/O Pins '************************************************************************************************* '************************************************************************************************* 'VAR section '************************************************************************************************* '************************************************************************************************* 'Interrupt Entry ($000) '************************************************************************************************* INTERRUPT nocode 115200 TASKS RUN,4 goto IsrStart '************************************************************************************************* 'Application Sub/Func/Task Declarations '************************************************************************************************* myTask TASK '************************************************************************************************* 'Reset Entry (page 0) '************************************************************************************************* PROGRAM Start '************************************************************************************************* 'Application Code '************************************************************************************************* Start: ' ------------------------------------------------------------------------------------------------ ' Initialization ' ------------------------------------------------------------------------------------------------ TASKS SET,0,myTask,10 'use taskslot 0 for myTask TASKS ENABLE MainLoop: ' ------------------------------------------------------------------------------------------------ ' Mainloop ' ------------------------------------------------------------------------------------------------ goto MainLoop '************************************************************************************************* 'Application Sub/Func/Task Code '************************************************************************************************* TASK myTask ENDTASK '************************************************************************************************* 'Interrupt Code (starts at last codepage) '************************************************************************************************* '{$ifdef SX18} ADDRESS $600 '{$endif} '{$ifdef SX20} ADDRESS $600 '{$endif} '{$ifdef SX28} ADDRESS $600 '{$endif} '{$ifdef SX48} ADDRESS $E00 '{$endif} '{$ifdef SX52} ADDRESS $E00 '{$endif} IsrStart: 'target address for GOTO in INTERRUPT returnint '************************************************************************************************* 'Application Data '************************************************************************************************* 'end of file
TASKS RUN must be given prior to TASKS SET or there are compilation errors.
I'd like to jump to the interrupt code leaving the largest amount of space for the SUB jumptable.
Unfortunately, I cannot place TASKS RUN at IsrStart.
My proposal is to leave TASKS RUN at the current position (after INTERRUPT keyword),
but to place the code generated by TASKS RUN, when RETURNINT is encountered.
That saves valuable codespace for the SUB jumptable (which also holds entries for TASK routines).
I don't see any problems it would give for the code, other than that you must suspend
some output to the .SRC file until RETURNINT is encountered.
regards peter
Post Edited (Peter Verkaik) : 7/18/2009 10:04:22 AM GMT
Comments
Yes, I see. The main problem is that you cannot use TASKS SET until after TASKS RUN appears in the listing.
I don't want to postpone the TASKS RUN code until RETURNINT because that would make the TASKS jittery because the other interrupt code will most likely be a variable number of cycles.
What I propose is a TASKS INIT, which will setup all the task variables but will not generate the task code. This will allow TASKS SET to be used after TASKS INIT. Later in the program when TASKS RUN is used, it will know not to define the variables again.
I think that would solve the problem. Yes ? Let me know, if that would work I'll implement it.
Bean.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
Yes, TASKS INIT would do it. TASKS INIT would be like a directive, not generating
any code but just declaring the internal task variables.
And if left out, TASKS RUN would declare the variables just as it does now.
The taskcode by itself is already jittery, and usually I place my own interrupt code
before TASKS· RUN, but I see that using TASKS INIT gives the option to place
task code before other interrupt code.
regards peter
· Give this a try. Syntax is TASKS INIT {, MAXTASKS} if you specify the MAXTASKS on the TASKS RUN line, it must match the value given in TASKS INIT (even if that value is the default of 5).
· I've included a little test program and output (test.sxb and test.src).
· Let me know if this works for you.
Bean.
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
Post Edited (Bean (Hitt Consulting)) : 7/20/2009 9:29:39 PM GMT
If I use (current way)
INTERRUPT 115200
· TASKS RUN,3,10··· '3 taskslots, tasktick = 10/115200 seconds
RETURNINT
then I get a compilation error.
TASKS RUN does not accept 2 arguments
If I use
INTERRUPT 115200
· TASKS INIT,3··· '3 taskslots, if 3 omitted then·5 taskslots
· goto IsrStart
'
IsrStart:
· TASKS RUN,3,10
RETURNINT
then I get a compilation error
If I use
INTERRUPT 115200
· TASKS INIT,3··· '3 taskslots, if 3 omitted then·5 taskslots
· goto IsrStart
'
IsrStart:
· TASKS RUN,10·· 'tasktick = 10/INTERRUPTRATE seconds
RETURNINT
then it is alright
So, if TASKS INIT is not used, TASKS RUN must take 1 or 2 arguments (tasktick) or (taskslots,tasktick).
If TASKS INIT is used, TASKS RUN must take 1 argument (tasktick)
Also, using
· TASKS INIT,3,10
does NOT give error
regards peter
Unless I'm missing something else I think you should have used "TASKS RUN 10, 3" instead of "TASKS RUN 3, 10".
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Does that byte of memory hold "A", 65, $41 or %01000001 ?
Yes it does...
·
You are right. I swapped·the arguments.
So it appears·ok.
regards peter