Using cognew more than once referencing the same DAT space
R Pankau
Posts: 127
Is this possible?·
for instance.·
· cog := cognew(@memory, 0)
· cog2 := cognew(@interrupt, 0)
I thought I was on to something when I put another ORG 0 just above the interrupt label and it worked but I think now everything above it is skipped.·· I can't use two ORG 0 directives in the same DAT can I?
So the real question is:· How can one start seperate cogs with different asm functions from a single Spin module?· I wanted to put a very simple routine in a cog to mimic a time interrupt like this.·
but I also would like the asm above it to continue to operate in a different cog.·
thanks.
for instance.·
· cog := cognew(@memory, 0)
· cog2 := cognew(@interrupt, 0)
I thought I was on to something when I put another ORG 0 just above the interrupt label and it worked but I think now everything above it is skipped.·· I can't use two ORG 0 directives in the same DAT can I?
So the real question is:· How can one start seperate cogs with different asm functions from a single Spin module?· I wanted to put a very simple routine in a cog to mimic a time interrupt like this.·
interrupt mov Time,cnt add Time,timer1 again waitcnt Time,timer1 wrlong all_ones,ptr_int_flag jmp #again
but I also would like the asm above it to continue to operate in a different cog.·
thanks.
Comments
As I explained in my Tutorial, ORG 0 just resets the internal counting of COG cells. That's all. Has nothing to do with memory allocation in the HUB, just with "counting numbers" in the COG. So it makes no sense at all to use anything else but ORG 0.
When use COGNEW it starts at the address you give loading whatever into the COG from the beginning.
It's all extraordinary simple!
In this thread Chip Gracy's message may·explain·using org. The propeller tool 1.05.7 in the downloads probably has this org embellishment and the $ operator, so don't download his program in this thread.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
On the other hand you must not use any variables from the part after the second ORG in "memory" (of course).
Or post the full code...
This looks funny.. Do you really want to output an SDA pulse of 100 ns? SDA is "pulled-down", I presume..
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Here is the code
·Sounds like I need to make my definitions in different places.· Am I incorrect in my assumption that all reserved words need to be at the end?· or is that just at the end of the respective code that will use it?· I put all definitions at the end of DAT for both routines.
That will likely be your problem. The Cog addresses allocated to the data after the second ORG may well be the same as those used by code before that second ORG.
What you want is ...
DAT
ORG 0
First Assembler Code
Data associated with this Code
ORG 0
Second Assembler Code
Data associated with this code
Thanks!
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔