And the fact that there is a require waitcnt... seems to imply that this is coming from the spin code interpreter... and there is an error in the memory move routine.
rjo_ and all,
Sorry for the confusion..... This is not an issue with the spin code interpreter, and there is not an error in the memory move routine.
This is a result of a 2-dimentional way of previous thinking and getting used to the 3-dimentional approach the Propeller uses. Basically what I am saying is that this is my fault.
Then what is going on with this code? ...and why does the waitcnt seem to work?
Since the Propeller is a true multiprocessor, what happens is that when you launch a new cog to perform a function on a separate processor, the initial cog or processor continues and
reads a value BEFORE the second cog has had a chance to write to it.
The simple fix is to place a delay in the first cog, so that you give the second cog a chance to update the correct value.
The correct or most efficient fix is to utilize a 'Flag' variable that is monitored by the first cog, but is updated by the second cog.
I hope this makes some sense, and again I apologize for the confusion.
[b]PUB[/b] AddNums(Num1,Num2):Flag
Num1_ := Num1
Num2_ := Num2
[b]cognew[/b](@entry, @Num1)
'waitcnt(cnt+10000)
'return Flag
[b]repeat[/b] [b]while[/b] Flag == 0
[b]return[/b] Num1
[b]DAT[/b]
[b]org[/b]
entry
[b]mov[/b] t1, [b]par[/b] ' Move argument address into t1
[b]add[/b] t1, #8 ' Point to 3rd argument ( In this case 'Flag' )
[b]wrlong[/b] Zero, t1 ' Clear 'Flag before we start'
[b]add[/b] Num1_,Num2_ ' Add Num1 to Num2
[b]wrlong[/b] Num1_, [b]par[/b] ' Return result to Num1
[b]wrlong[/b] One, t1 ' Set 'Flag when we are done'
[b]CogId[/b] CogNum ' Get COG ID
[b]CogStop[/b] CogNum ' Stop this COG
CogNum [b]long[/b] 0 ' Reserved variables
Num1_ [b]long[/b] 0
Num2_ [b]long[/b] 0
Zero [b]long[/b] 0
One [b]long[/b] 1
t1 [b]res[/b] 1
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
You aren't guilty of anything... there is a whole bunch of info on the proper use of flags... and even Graham has put questions in on this exact question...
I just hadn't figured it all out yet... and I honestly hadn't gotten far enough with my own thinking to see the connection.
Nice try...from a nice guy... but this was all me... again!!![noparse]:)[/noparse]
I'm going to try to create a bunch of examples from different points of view... just haven't gotten that far yet[noparse]:)[/noparse]
AND... please feel free to be just a little more liberal with me... if I missed something... then don't you take the blame for it.
We are all in the learning curve of this New Chip, and I am guilty for not having my head around the problem prior to releasing code in the first place.
I take criticism very constructively, and if there is a problem it needs to be addressed so that others may benifit.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Beau Schwabe
IC Layout Engineer
Parallax, Inc.
' EXAMPLE 20
'
' THIS EXAMPLE MEASURES THE CHARGE TIME OF A CAPACITOR,
' USES TWO COGS, AND HAS VIDEO OUTPUT
'************************************************************************
'IMPORTANT: This example may require an understanding of examples 6 & 9
'************************************************************************
Your code doesn't compile for me like above (Error: Expected "(" with the cursor after "VideoDisplay.Start)
By trial and error I found out that by changing code to VideoDisplay.Start(12) everything seems to work fine.
I should add that I'm using a "Parallax Demo Board Rev.F".
The TV Terminal driver requires a single parameter ... the lowest pin number of the block of 4 pins used for video output. This actually has to be a multiple of 4. I don't know why it wasn't mentioned in the original source. You may notice that pretty much everyone's posted example has this parameter supplied.
So, in the example 01 : i don't understand how / where is defined the function waitcnt and the variable cnt.
If they are implemented system items, why don't you say ? I didn't read the manual, of course, so why I read this topic....
What is the ratio light / shadow of each blink, for instance : I suppose that it's 1 : 1, but how long is each phase of the process ? 12.5ns ? Is it sufficient to see 5 flashs ?
If you load the example into the propeller IDE tool, you will notice that reserved words are in bold letters. And that waitcnt and cnt are reserved.
If you open the manual's pdf and search on these words you will quickly get up to speed on what they do and mean.
In this particular example, the waitcnt pause is 1/2 second.
If you read the more comments version of this file, you will see:
' -- The LED, at port A16, is on for 1/2 second and off for 1/2 second.
' -- The System Counter increments by one for every System Clock pulse. Thus, if the
' System Clock is running at 80MHz, the System Counter will increment 80 million times
' in one second; and every counter increment will take 12.5ns (1/80MHz).
' Each WaitCnt statement below is set to cause a 1/2 second wait:
' 40_000_000 counter increments * 12.5ns = 500ms (1/2 second)
Tx for your reply.
But before buying one propeller, and all accessories needed to run it, you surely understand that somebody is looking around what can be done, and what not. Particularly if a chip, the propeller in this case, is not so much hearded about in the country where this person is living, and particularly if the person don't know the spin language (but knows the C one) ...
Of course you understand this, as this is explicitly said in the first pinned post of the examples.
So I have not the propeller IDE tool, and I can't notice anything in bold letters.
Now I understand a little more about the period of blink, but i don't understand what is the variable cnt, and why the sum to the 1/2 period blinking.
If you say me where I can find the mythical manual's pdf (none pinned reference to this book), i surely will be able to search more about the cnt variable.
Click on the Paralax logo at the top of the page. Then find a link to the propeller pages. Look for "downloads" link. Download the one with the IDE tool and manual combined.
Install the program.
Tx a lot for your link.
I will take a look at this document. The propeller seems really an excellent product.
I am wondering why there is not more of infos about it in the robotic forums, and so on....
Martin, in a previous post a few pages back you mentioned having heard from Dave at that time. It appears he hasn't been on the forums in almost a year. I hope everything is okay with him.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔ Chris Savage Parallax Tech Support
And here's is a little democode to show how FullDuplexSerial works on the serial connection
you are using to program the chip (PINs30,31)
'ATTENTION! You HAVE TO download the code to the EEPROM ! (Key F11)
'opening the comport with PST.EXE causes a reset of the propeller
'after reset, the propeller does its bootprocess that includes loading the content of the EEPROM
'to the RAM. So last content of the RAM will you overwritten by the last content of the EEPROM
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
OBJ
debug : "FullDuplexSerial"
VAR
long X
PUB main
debug.start(31, 30, 0, 9600)
X := 0
repeat
X++
debug.str(string("X="))
debug.dec(X)
debug.str(string(" Hello World"))
debug.tx(13)
waitcnt(ClkFreq + cnt)
@Parallax-Team:
This kind of debugging is SO EASY
as it needs NOTHING MORE than any kind of PropBoard
This democode should be delivered inside the manual AND as SPIN-File
in the Library-demo-folder
best regards
Stefan
Post Edited (StefanL38) : 10/6/2008 1:39:16 AM GMT
Comments
And the fact that there is a require waitcnt... seems to imply that this is coming from the spin code interpreter... and there is an error in the memory move routine.
Rich
AND if that is the case, then there would be a debate about what to do...
I certainly wouldn't change the interpreter... I would just put an expansive series of examples in the tricks and traps sticky.
Rich
Sorry for the confusion..... This is not an issue with the spin code interpreter, and there is not an error in the memory move routine.
This is a result of a 2-dimentional way of previous thinking and getting used to the 3-dimentional approach the Propeller uses. Basically what I am saying is that this is my fault.
Then what is going on with this code? ...and why does the waitcnt seem to work?
Since the Propeller is a true multiprocessor, what happens is that when you launch a new cog to perform a function on a separate processor, the initial cog or processor continues and
reads a value BEFORE the second cog has had a chance to write to it.
The simple fix is to place a delay in the first cog, so that you give the second cog a chance to update the correct value.
The correct or most efficient fix is to utilize a 'Flag' variable that is monitored by the first cog, but is updated by the second cog.
I hope this makes some sense, and again I apologize for the confusion.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
You aren't guilty of anything... there is a whole bunch of info on the proper use of flags... and even Graham has put questions in on this exact question...
I just hadn't figured it all out yet... and I honestly hadn't gotten far enough with my own thinking to see the connection.
Nice try...from a nice guy... but this was all me... again!!![noparse]:)[/noparse]
I'm going to try to create a bunch of examples from different points of view... just haven't gotten that far yet[noparse]:)[/noparse]
AND... please feel free to be just a little more liberal with me... if I missed something... then don't you take the blame for it.
Rich
We are all in the learning curve of this New Chip, and I am guilty for not having my head around the problem prior to releasing code in the first place.
I take criticism very constructively, and if there is a problem it needs to be addressed so that others may benifit.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Beau Schwabe
IC Layout Engineer
Parallax, Inc.
I was enjoying the code examples[noparse]:)[/noparse]
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
My web site -- > www.floodhound.com <-- take a look if you like
Mind You, me <- beginner [noparse]:)[/noparse]
Your code doesn't compile for me like above (Error: Expected "(" with the cursor after "VideoDisplay.Start)
By trial and error I found out that by changing code to VideoDisplay.Start(12) everything seems to work fine.
I should add that I'm using a "Parallax Demo Board Rev.F".
Can You explain?
Thanks,
Christoph
I am looking about your example code.
So, in the example 01 : i don't understand how / where is defined the function waitcnt and the variable cnt.
If they are implemented system items, why don't you say ? I didn't read the manual, of course, so why I read this topic....
What is the ratio light / shadow of each blink, for instance : I suppose that it's 1 : 1, but how long is each phase of the process ? 12.5ns ? Is it sufficient to see 5 flashs ?
If you open the manual's pdf and search on these words you will quickly get up to speed on what they do and mean.
In this particular example, the waitcnt pause is 1/2 second.
If you read the more comments version of this file, you will see:
' -- The LED, at port A16, is on for 1/2 second and off for 1/2 second.
' -- The System Counter increments by one for every System Clock pulse. Thus, if the
' System Clock is running at 80MHz, the System Counter will increment 80 million times
' in one second; and every counter increment will take 12.5ns (1/80MHz).
' Each WaitCnt statement below is set to cause a 1/2 second wait:
' 40_000_000 counter increments * 12.5ns = 500ms (1/2 second)
But before buying one propeller, and all accessories needed to run it, you surely understand that somebody is looking around what can be done, and what not. Particularly if a chip, the propeller in this case, is not so much hearded about in the country where this person is living, and particularly if the person don't know the spin language (but knows the C one) ...
Of course you understand this, as this is explicitly said in the first pinned post of the examples.
So I have not the propeller IDE tool, and I can't notice anything in bold letters.
Furthermore, i don't read
in the example code, but
Now I understand a little more about the period of blink, but i don't understand what is the variable cnt, and why the sum to the 1/2 period blinking.
If you say me where I can find the mythical manual's pdf (none pinned reference to this book), i surely will be able to search more about the cnt variable.
Tx for your infos.
Install the program.
Or just click this and save: http://www.parallax.com/dl/sw/propeller/Setup-Propeller-Tool-v1.05.5.exe
I will take a look at this document. The propeller seems really an excellent product.
I am wondering why there is not more of infos about it in the robotic forums, and so on....
But before go forward, with the example 04, I need to understand one point : why this mysterious 20, to size the stack, in the example 03 ?
Why not 19 or 21 ?
Sorry, but the manual talks for a long time with a stack sized with 9.
And as examples are here to explain a bit, why 20 ?
When a routine ends, is the stack free ?
Or can we just do 20 calling of each routine ?
Sorry for my dumbass questions, but the video monitor seems unextricable if I don't understand the example 03.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Chris Savage
Parallax Tech Support
to have a feedback of your program for debugging you could use the FullDuplexSerial-object
download the Propeller serial Terminal-Software "PST.EXE" here
www.parallax.com/Portals/0/Downloads/sw/propeller/PST.exe.zip
And here's is a little democode to show how FullDuplexSerial works on the serial connection
you are using to program the chip (PINs30,31)
@Parallax-Team:
This kind of debugging is SO EASY
as it needs NOTHING MORE than any kind of PropBoard
This democode should be delivered inside the manual AND as SPIN-File
in the Library-demo-folder
best regards
Stefan
Post Edited (StefanL38) : 10/6/2008 1:39:16 AM GMT