propBASIC 'TASK ... ENDTASK'
Rsadeika
Posts: 3,837
"* SUBs and FUNCs are not shared between cogs." Does anybody have any ideas of how to get around this problem. I would like to declare a FUNC in the main cog, but be able to use it, or call it in different TASKs. I would like to create one 'serin', 'serout' function, and be able to use it, or call it, in multiple TASKs. It looks like a lot of duplicate code being used if you have to declare a new 'serin/serout' FUNC in the different TASKs. Any code snippets for achieving this would be appreciated.
Thanks
Ray
Thanks
Ray
Comments
You can't do that. TASKs are in a different cog. One cog cannot "see" the code in a different cog.
Just create the same subroutine for the TASK that needs it.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Ray
Yes, LOAD just inserts the code.
You COULD use a seperate task for SERIN and SEROUT, but I think you are making it more complecated than it needs to be. The amount of code generated by SERIN or SEROUT is not that much. If you use it alot, put it in a subroutine. If you use SERIN or SEROUT in multiple cogs, just put the subroutine in each of them.
Now putting SERIN in a seperate task will have the advantage of not missing any incoming characters.
And I do have one program that puts SEROUT in a seperate cog because it needs to acquire data in real-time and it cannot afford to wait for SEROUT to finish sending the data string.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]
Ray
www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Ray
'==============
TASK BlueT LMM
message data "This is the place!",13
rxResult var long
do
serin 5, T57600, rxResult
if rxResult = 13 then exit
loop
serout 6, T57600, message
pause 1000
do
serin 5, T57600, rxResult
if rxResult = "a" then
high 0
high 3
endif
if rxResult = "b" then
low 0
low 3
endif
loop
ENDTASK
BTW, that's a very small task and there is no reason to make it LMM -- keep it in one cog and run it full speed.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Jon McPhalen
Hollywood, CA
Ray
· Try making the SEROUT pin high (idle) well before you try sending data.
· Also you need to put a zero at the end of the string. This is only done for you with in-line strings.
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]
Post Edited (Bean) : 5/17/2010 9:09:04 PM GMT
Ray
Bean
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Use BASIC on the Propeller with the speed of assembly language.
PropBASIC thread http://forums.parallax.com/showthread.php?p=867134
March 2010 Nuts and Volts article·http://www.parallax.com/Portals/0/Downloads/docs/cols/nv/prop/col/nvp5.pdf
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
There are two rules in life:
· 1) Never divulge all information
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
If you choose not to decide, you still have made a choice. [noparse][[/noparse]RUSH - Freewill]