Draft for Review - PE Kit Lab - Fundamentals: Propeller I/O and Timing Basics
Andy Lindsay (Parallax)
Posts: 1,919
Attached is the 0.9 version of the second in the Propeller Education Kit lab series·- Fundamentals: Propeller I/O and Timing Basics.·
The 1.0 version will be posted to the web next week with your input.·
Please send corrections to editor@parallax.com, and post suggestions and recommendations to this thread.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
The 1.0 version will be posted to the web next week with your input.·
Please send corrections to editor@parallax.com, and post suggestions and recommendations to this thread.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Comments
·I reread your instuctions & e-mailed you , so far I like it.
Thank's Brian
Post Edited (truckwiz) : 12/2/2006 1:04:49 PM GMT
Up to page 14 , the repeat loop variations have me a little stumped , this is·how I interpreted how·you wanted the code wrote . I can't get it to work. (keep in mind I am doing this on a propeller demo board)
Thank's Brian
CON
_clkmode = xtal1 + pll16x
_xinfreq = 5_000_000
pub blink_led
dira[noparse][[/noparse]16..23] ~~
outa[noparse][[/noparse]16..23] ~
repeat·until outa[noparse][[/noparse]16..23] == 20
· waitcnt(clkfreq / 2 + cnt)
Post Edited (truckwiz) : 12/2/2006 7:23:05 PM GMT
All the code on that page work's , except
repeat until outa[noparse][[/noparse]9..4] == 20
repeat while outa[noparse][[/noparse]9..4] < 20
If I add ++ It works
repeat until outa[noparse][[/noparse]9..4] ++ == 20
and
repeat while outa[noparse][[/noparse]9..4] ++ < 20
Thanks, Brian
The goal with those variations is to either repeat a loop "while" something is true, or "until" something happens.· As written, your loop will repeat a 1/2 s delay while outa[noparse][[/noparse]16..23] is equal to 20.· Instead, try adding 1 to outa[noparse][[/noparse]23..16] each time through the loop, either until it gets to 20 or while it's less than 20.· Below is the "until outa[noparse][[/noparse]21..16] equals 20"·version.· For the "while outa[noparse][[/noparse]21..16] is less than·20" version, use repeat while outa[noparse][[/noparse]21..16]·< 20.
At the point where you get to the Pre and Post Operator Positions section, there are some examples where outa[noparse][[/noparse]9..4]++, which will be outa[noparse][[/noparse]21..16] for your board, is removed from inside the repeat loop and incremented with ++ right inside the repeat condition.· I think for your board, the·first of those examples·should look like this:
·
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 12/2/2006 7:45:23 PM GMT
I understand how it work's now ,but when I read it the first time it seemed like there's a step missing.I got side tracted on moving the outa[noparse][[/noparse]21..16] ++ above the waitcnt that I didn't notice that it was missing. ( I hope that made sense !)
Thanks, Brian
pub blink_led
dira[noparse][[/noparse]21..16] ~~
repeat while outa[noparse][[/noparse]21..16] < 20
·waitcnt(clkfreq / 2 + cnt)
·outa[noparse][[/noparse]21..16] ++
Post Edited (truckwiz) : 12/2/2006 9:19:18 PM GMT
Still pluging away at it , will try to finish by monday night ( got a little side tracked on assembly)
Thanks , Brian
dt := clkfreq········ To:
dt := clkfreq / 1000
to flash the LEDs at a 1 ms rate instead of a 1 sec rate it does not seem to work? But if I use a smaller value (such as 600 instead of 1000) I see the lights flicker which is what I imagine would happen with a 1 ms time base. Any ideas?
Thanks Tim
The Propeller chip's system clock is only running at 1 MHz in that example. By changing the time to 1 ms, it's causing the program to run out of calculation time before the next iteration. Replace PLL1x with PLL2x, and it'll work.· (PLL2x, PLL4x, ... PLL16x will work)
In this first lab, the code is not particularly efficient. By the time you get to the forthcoming counters lab (which should be out this week), you'll have seen several different ways to get this job done.
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
Post Edited (Andy Lindsay (Parallax)) : 4/16/2007 6:53:34 PM GMT
I have the PEK.
My programs have suddenly begun stopping prematurely.
I had completed the 12/7/6 version of the lessons up to the repeat while ...AND... case (page 16 of 29 top, just before "Some other Vocabulary").
Then it would only count to 15 (not 20) and stop (all LEDS off.)
What I had been doing is, starting with the first loop example, I just added each new example to the program at the beginning, so all examples were in the same file.
Anyway, after the AND example failed, I went back to try simpler programs, and got premature termination on them to.
For example, even the simple setup program: [noparse][[/noparse]edited 8/2/2007]
will turn on the LED but it goes back off in a few seconds or fraction of second.
(The actual time seems to vary from run to run).
I've tried disconnecting and reconnecting the board, and reloading the DoNothing program. Sometimes it will appear to work for the first few programs tried after being off a while, but eventually reverts to the early termination behavior.
I had rearragned some LEDs and circuit wires occasionally during the exercises,
but I've been over the board and it seems to be correctly wired.
Is there any way to test the chips for damage? As you see, even the "pin test" program behaves erratically.
JoeA
Post Edited (JoeA) : 8/3/2007 3:14:33 PM GMT
Looks like I don't know how to include programs in posts.
There were actually brackets and pin numbers in the dira and outa above,
and I don't know what changed the font size.
·8/2: original post fixed per advice below
JoeA
Post Edited (JoeA) : 8/3/2007 3:26:00 AM GMT
I've just bought a PE kit (USB) so I can learn about the Propeller chip. I'm getting exactly the same problem as JoeA. An empty repeat block does not stop the program from ending. It runs for varying times then resets. I set up the breadboard correctly and cleared all the tests in the setup lab without any problems.·Does this mean I have a faulty chip?
Thanks,
Dan
make sure that your repeat command is able to execute every time
try using a debug terminal to see where/if your program hangs up
make sure that nothing is in the repeat loop. Use the visual indentation indicators to check.
I tried a fresh battery - same results.
I double checked the code:
Same results.
I then tried running the code with the serial terminal enabled - problem vanished! So I thought, ah, maybe it's something to do with the usb connection. I had noticed the blue light blinking periodically even though I wasn't loading anything to the chip. I disconnected the usb and ran the program from the eeprom - again no problem.
So, I think it may have something to do with some status check the OS is running on the usb/com which interupts the program.
Daniel,
Do you have HotSync of some other PDA manager running? If you disable it, does it resolve the problem, or do the symptoms still persist?
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.
I've had a look at what might be causing noise on the usb line. I think I identified the culprit as the media manager for my phone (Sony Ericsson). I disabled it and everything seems to be working OK now.
Thanks,
Dan
Excellent, thanks for letting us know.
Andy
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Andy Lindsay
Education Department
Parallax, Inc.