Shop OBEX P1 Docs P2 Docs Learn Events
View pins changing with ViewPort — Parallax Forums

View pins changing with ViewPort

HannoHanno Posts: 1,130
edited 2009-11-10 04:25 in Propeller 1
The attached program uses a counter to toggle pins. With ViewPort, you can set a breakpoint and/or single step through the code to watch the counter increment in the loop. ViewPort also draws a diagram of the Propeller's pins in the Debug view. Here you'll see the pins being manipulated. In the screenshot you should see:
- the cog is paused on the breakpoint in line 33
- the value of ctr is "6". You can see this in the mouseover window that pops up when I hover over the "ctr" variable name. you can also see it in the "watch" pane on the bottom left.
- pins 1 and 2 are high- they are marked red in the bottom center Propeller diagram.

As you single step or run through the program, the ctr will be incremented each time through the repeat loop. When line 32 is highlighted, the "outa" instruction is just about to be run. This can be confusing- for example, if ctr is currently "5", but the outa instruction has NOT run yet, then the pin output will be that from the last outa instruction, so pin 2 will be high. Confusing, but correct.
[img]http://mydancebot.com/linked/debug pin toggle.png[/img]
Hanno

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Co-author of the official Propeller Guide- available at Amazon
Developer of ViewPort, the premier visual debugger for the Propeller (read the review here, thread here),
12Blocks, the block-based programming environment (thread here)
and PropScope, the multi-function USB oscilloscope/function generator/logic analyzer

Comments

  • HannoHanno Posts: 1,130
    edited 2009-11-10 04:25
    You can't attach spin files on these forums?
    Here it is:
    {***********************************************************************
    * (C) 2009 myDanceBot.com, Inc.                                        *
    * Step through a spin program and watch how the Propeller toggles pins *
    * AppletImage=scope.gif                                                *
    ************************************************************************
    This applet shows how you can use ViewPort's Spin Debugger to watch as a 
    variable is incremented in a repeat loop and is used to set the pin states
    of the Propeller.  
    Set a breakpoint in the "ctr:=ctr" line (line 33) and start the debugger with "F5".  
    The program will pause in that line and the value of the "ctr" variable" will
    match the state of pins 0..3
    }
    CON
     _clkmode        = xtal1 + pll16x
     _xinfreq        = 5_000_000
    OBJ
     vp    :       "Conduit"     'transfers data to/from PC
     qs    :       "QuickSample"         'samples INA continuously in 1 cog to 20mhz 
    pub demo|frame[noparse][[/noparse]400],ctr
     vp.register(qs.sampleINA(@frame,1)) 'sample INA with 1 cog up to 20Mhz
     vp.config(string("var:io,ctr(min=0,max=15)"))
        'share memory with ViewPort, io,ctr.  Ctr's range is 0-15.
     vp.config(string("lsa:view=io,timescale=1ms"))
        'View io with a timescale of 1ms with the lsa graph
     vp.config(string("start:lsa"))
        'Start in lsa mode
     vp.share(@ctr,@ctr)
        'Share ctr
     dira[noparse][[/noparse]3..0]~~ 
     repeat
      repeat ctr from 0 to 15
        outa[noparse][[/noparse]3..0]:=ctr
        ctr:=ctr           'set breakpoint here and hit "f5".  
                           'The value of "ctr" will correspond with the pin diagram
    
    

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Co-author of the official Propeller Guide- available at Amazon
    Developer of ViewPort, the premier visual debugger for the Propeller (read the review here, thread here),
    12Blocks, the block-based programming environment (thread here)
    and PropScope, the multi-function USB oscilloscope/function generator/logic analyzer
Sign In or Register to comment.