Shop OBEX P1 Docs P2 Docs Learn Events
Draft for Review - PE Kit Lab - Fundamentals: Propeller I/O and Timing Basics — Parallax Forums

Draft for Review - PE Kit Lab - Fundamentals: Propeller I/O and Timing Basics

edited 2008-12-23 02:40 in Propeller 1
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.

Comments

  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-02 05:04
    Andy,
    ·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
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-02 19:04
    Andy,
    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
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-02 19:31
    Andy,
    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
  • edited 2006-12-02 19:39
    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.

    pub blink_led
    
        dira[noparse][[/noparse]21..16] ~~
    
        repeat until outa[noparse][[/noparse]21..16] < 20 
           waitcnt(clkfreq / 2 + cnt)
           outa[noparse][[/noparse]21..16]++<!-- Edit -->
    


    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:

    pub blink_led
    
        dira[noparse][[/noparse]21..16] ~~
    
        repeat until outa[noparse][[/noparse]21..16] ++ == 19 
           waitcnt(clkfreq / 2 + cnt)
    

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.

    Post Edited (Andy Lindsay (Parallax)) : 12/2/2006 7:45:23 PM GMT
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-02 21:14
    Andy,
    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
  • [Deleted User][Deleted User] Posts: 0
    edited 2006-12-04 04:42
    Andy ,
    Still pluging away at it , will try to finish by monday night ( got a little side tracked on assembly)

    Thanks , Brian
  • tmatuctmatuc Posts: 6
    edited 2007-04-16 16:17
    In the "TimeCounter.spin"· from P.E. kit example when I change

    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
  • edited 2007-04-16 17:52
    Hi tmatuc,

    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
  • JoeAJoeA Posts: 33
    edited 2007-08-01 21:29
    Andy,
    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]

    PUB LedOn                      ' Method declaration
                                                 
        dira[noparse][[/noparse]4] := 1               ' Set P4 to output
        outa[noparse][[/noparse]4] := 1               ' Set P4 high
        repeat     ' Endless loop prevents program from ending
    
    

    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
  • JoeAJoeA Posts: 33
    edited 2007-08-01 21:32
    PS re above
    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
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2007-08-01 22:10
    use the code /code pair instead of the quote /quote pair.
  • JoeAJoeA Posts: 33
    edited 2007-08-03 03:22
    Fred, thanks for formatting advice. I corrected the original post.· JoeA
  • Daniel Lloyd-WoodDaniel Lloyd-Wood Posts: 14
    edited 2008-12-18 22:02
    Hello,

    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
  • SRLMSRLM Posts: 5,045
    edited 2008-12-19 00:38
    Can you post your code? A couple of things to look for:

    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.
  • Fred HawkinsFred Hawkins Posts: 997
    edited 2008-12-19 10:19
    Dan, my first instinct is to change your 9v battery for a fresh one.
  • Daniel Lloyd-WoodDaniel Lloyd-Wood Posts: 14
    edited 2008-12-19 23:19
    OK. I've done some tests with some interesting results.

    I tried a fresh battery - same results.
    I double checked the code:
    '' File: LedOnP4.spin
    
    PUB LedOn                                    ' Method declaration
                                                 
        dira := 1                             ' Set P4 to output
        outa := 1                             ' Set P4 high
    
        repeat                                   ' Endless loop prevents program from ending
    


    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.
  • edited 2008-12-20 00:40
    Daniel Lloyd-Wood said: "So, I think it may have something to do with some status check the OS is running on the usb/com which interrupts 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.
  • Daniel Lloyd-WoodDaniel Lloyd-Wood Posts: 14
    edited 2008-12-20 23:32
    Hi Andy,

    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
  • edited 2008-12-23 02:40
    Dan,

    Excellent, thanks for letting us know.

    Andy

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Andy Lindsay

    Education Department
    Parallax, Inc.
Sign In or Register to comment.