Draft for Review - PE Kit Lab - Fundamentals: Methods and Cogs
Andy Lindsay (Parallax)
Posts: 1,919
Attached is the 0.8 version of the·third in the Propeller Education Kit lab series·- Methods and Cogs.·
Please send corrections to editor@parallax.com, and post suggestions and recommendations to this thread.
An updated (probably 0.9) version with questions, exercises and projects along with·some additional information about waitpeq and·PUB vs. PRI·will be posted after Parallax reopens on Jan 2.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Please send corrections to editor@parallax.com, and post suggestions and recommendations to this thread.
An updated (probably 0.9) version with questions, exercises and projects along with·some additional information about waitpeq and·PUB vs. PRI·will be posted after Parallax reopens on Jan 2.·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Comments
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
OS-X: because making Unix user-friendly was easier than debugging Windows
links:
My band's website
Our album on the iTunes Music Store
What about to include more advance ways to use cogs, in asm and spin ?
Like Steve ask... and more .....
Many concepts are not clear for many people, specially when we want to explore, more advance features..., there are many posts asking this kind of questions.
I've post a big effort to not ask ...but sometimes is really impossible without help, many hours wasted trying to solve certain problems, could be avoided.
Regards.
Alberto.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Any word on the updated version?, or the next lesson
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
John R.
8 + 8 = 10
I'm reading through Methods & Cogs . In figure 2 you are using ina[noparse][[/noparse]23] to change the flow of the program , I thought you had to declare [noparse][[/noparse]23] a input before you used it ?
Thanks ,Brian
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
ina[noparse][[/noparse]23] == 1
or
ina[noparse][[/noparse]23] == 0
Brian
PS. here's the code I was working on , now it works :-)
Post Edited (Brian Beckius) : 2/7/2007 6:47:19 PM GMT
I think this one only runs LauchBlnkCogs and does not fall through to execute Blink(). At least, that's what I think I see when it runs.
My problem is knowing why it doesn't fall through. I've looked in the manual and read here and there. So far, I've no luck in finding an explanation.
Since this is the first instance of this [noparse][[/noparse]compiler?] behavior dropped on the beginning prop user maybe that explanation accompany this listing.
'' BlinkWithCogs.spin
VAR
long stack[noparse][[/noparse]30]
PUB LaunchBlinkCogs
cognew(Blink(4, clkfreq/3, 9), @stack[noparse][[/noparse]0])
cognew(Blink(5, clkfreq/7, 21), @stack[noparse][[/noparse]10])
cognew(Blink(6, clkfreq/11, 39), @stack[noparse][[/noparse]20])
PUB Blink( pin, rate, reps)
dira[noparse][[/noparse]pin]~~
outa[noparse][[/noparse]pin]~
repeat reps * 2
waitcnt(rate/2 + cnt)
!outa[noparse][[/noparse]pin]
Cog 0 never gets to the Blink method, but cogs 1, 2, and 3, do because the Blink method gets launched into each of them with three cognew commands.· Even though cog 0 runs out of commands and shuts itself down, cogs 1, 2, and 3 will still run for a while.
For background information on how a method behaves when it runs out of commands, download and examine pages 4 and 5 of I/O and Timing.· It's available from Propeller Education Kit Labs.
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 6/29/2007 1:49:30 AM GMT
Thanks for the quick reply. I hadn't thought about the cog 0 shutting down after launching the others. Which means that cognew loads a new spin interpreter. Guess I need to spend more time reading the manual. (PDF manual recommendation: bookmarks for lexicon entries or let us add comments at least)
I did the I/O and Timing already -- putting ducks in a row and knocking them down one by one -- and I confess I scanned that page looking mostly at the gray boxes.
I gather my question (why does BlinkWithCogs.spin stop executing after the third cognew and not fall through to Blink() probably with 0 values in the arguments?) has to do with the compiler's evaluation of method blocks. I am now getting a sense of Forth without a semicolon. That is, the top word (method) is all the program there is. The rest of what happens is what's called by the top method.
Which means that I will have to go back and rescan every damn bit of spin that I've been saving on my computer to undo my fall through execution hypothesis. Things ought to be a lot clearer now.
So my two cents: add a paragraph here, where your code adds a second PUB to make note of the compiler's behavior. Because up until this program* all the examples have been single method programs with execution dropping down the page, managed only by repeats, waitcnts and an if or two.
Fred
* Correction: actually its·page 3 (Methods and Cogs)·for the first instance·of two PUB's in·CallBlink.spin.· Main gets stuck in a repeat so I didn't bother to worry about falling through there.
Post Edited (Fred Hawkins) : 6/29/2007 6:55:48 AM GMT
Thanks for the update !
Keep up the good work.
I know some of us are all new to the propeller, with me shuffeling colllege classes and a family, some of us are all still willing to take the time to learn something new and persue our intresets .
Thak's for all the hard work .
Rob 7.
Ariba's PreSpin has a lexicon feature that lets you highlight a word in your spin files and click on the question mark icon to bring up the appropriate page in the manual's pdf.
If you don't highlight anything and click the question mark, the program's panel expands a bit to show you the list of entries with a scroll bar with the last viewed item highlighted. Single click on anything in the list to move to that page in the manual.
Notepad.exe can edit the index file so you can add your own bookmarks for the manual.
http://forums.parallax.com/forums/default.aspx?f=25&m=195896
I've attached an alternative index that includes the assembly language. The little program that does this can't handle duplicate entries so I put the assembly stuff at the tail of the file. Highlight the word 'assembly' in a spin file then click the question mark to put the manual at the beginning of chapter five. Then unhighlight the spin file and click the question mark to open the list at 'assembly language'. Opcodes are below, and spin commands are above.
Post Edited (Fred Hawkins) : 7/1/2007 1:45:47 PM GMT