Shop OBEX P1 Docs P2 Docs Learn Events
Debugging Question — Parallax Forums

Debugging Question

Does the "PST Debug LITE" Object still exist? If so where can I find it?

Thanks Blake

Comments

  • PublisonPublison Posts: 12,366
    edited 2017-03-27 19:03
  • Thank you.

  • Blake KochBlake Koch Posts: 39
    edited 2017-03-28 03:20
    Let me start with I'm working out of the book "Programming and Customizing the Multicore Propeller"

    I just downloaded the "PST Debug Lite" Object

    I'm working on page 91,92 of this book

    I had a error message after compiling this code that required me to Change the books code.

    From
    debug.Style(debug#COMMA_DELIMITED)
    debug.Start(115200)

    To

    debug.Start(debug#(COMMAS)

    To clear the error code. After doing so the example on page 87 Step1 and step2 worked perfect with just the debug.start(debug#COMMAS) name change.

    However in step 3 Page 91,92

    I have entered the text exactly as I see it written on page 91,92 when I try to run it nothing works right. the number on serial display are all over the place and the numbers do not add up.

    (SEE CODE IN LOWER MESSAGE)

    and what I get out the other end is just numbers all over the place. nothing lines up.

    Can anyone help me with what am I doing wrong?


    Thanks Blake
  • twm47099twm47099 Posts: 867
    edited 2017-03-28 02:41
    Since spin uses indentation to control blocks of code (repeats) you should post your code using the code feature of the forum.

    If you look at the list of small icons above the editing area, one of them is a C. If you click on that you will get [ code][ /code] (without the space after the [ and before the C or /.

    I place the cursor between the ] and the [ and hit enter a couple of times. Then you can just cut and paste your code from the proptool (or whatever IDE you use) between them. That way the we will be able to see the indentation and be able to help better.

    Tom
  • Blake KochBlake Koch Posts: 39
    edited 2017-03-28 03:13
    ' Test Timestamp from another cog
    'This example programs demonstrates an initial test a some
    'timestamps prototype code that fails to expose a memory bug
    
    'Important : this code has a hidden bug
    
    CON
      _clkmode = xtal1 + pll16x                                                                             'Crystal and PLL settings
      _xinfreq = 5_000_000                                                                                  '5MHz crystal x 16 = 80MHz
    
    OBJ
    
      debug : "PST Debug Lite"                                                                              'Serial communications object
    
    VAR
    
      long stack[40]                                                                                        'Ample stack for prototyping
      long m, s, ms, t, dt                                                                                  'Timekeeping variables
    
    PUB GO | minutes, seconds, milliseconds
    
      debug.Start(115200,debug#COMMAS)                                                                      'Start Debug cog
    
      cognew(TimerMS, @stack)                                                                               'Start timekeeping cog
    
      repeat 
        longmove(@minutes, @m, 3)                                                                           'Copy TimerMS vars
        debug.ListHome                                                                                      'Display values
        debug.Vars(@m, String("| minutes, seconds, milliseconds"))                                          '
        debug.break
    
    PRI TimerMS
    
      t := cnt                                                                                              'Current clock counter
      dt := clkfreq/1000                                                                                    'Ticks in 1 ms
    
      repeat                                                                                                'Infinat loop
        waitcnt(t+=dt)                                                                                      'Wait for the next ms
        ms++                                                                                                'Add 1 to millisecond count
        if ms == 1000                                                                                       'If millisecond = 1000
          ms := 0                                                                                           'Set ms to 0
          s++                                                                                               'Incriment second
        if s == 60                                                                                          'If second = 60
          s := 0                                                                                            'Set second to 0
          m++                                                                                               'Increment Minute
        if m == 60                                                                                          'If m equals 60
         m:=0                                                                                               'Set minute to 0
    
    

    Ok that's cool. Thanks for the help.
  • twm47099twm47099 Posts: 867
    edited 2017-03-28 03:59
    Blake,
    I have attached a copy of the version of "PST debug Lite.spin" that is used in the book.
    Note that you have to go back to using:
      debug.Style(debug#COMMA_DELIMITED)
      debug.Start(115200)
    

    When I run the program below with this version I get a printout that looks like the one on page 92.

    Try cutting and pasting the code in the yellow box into the prop tool.

    You will have to download the attached spin file. Go to where you currently have your version of PST debug lite.spin and rename that file (just add an x after lite). Then save the attached version of PST debug lite.spin to that folder.

    Hope this helps
    '' Programming and Customizing the Multicore Propeller Microcontroller
    '' Pages 91-92
    '' This example program demonstrates an initial test of a some
    '' timestamp prototype code that fails to expose a memory bug.
    
    '' IMPORTANT: This code has a hidden bug!!!
    
    CON
       
      _clkmode = xtal1 + pll16x               ' Crystal and PLL settings.
      _xinfreq = 5_000_000                    ' 5 MHz crystal x 16 = 80 MHz.
    
    OBJ
    
      debug  : "PST Debug LITE"               ' Serial communication object
    
    VAR
    
      long stack[40]                          ' Ample stack for prototyping
      long m, s, ms, t, dt                    ' Timekeeping variables
    
    PUB Go | minutes, seconds, milliseconds                                  
    
      debug.Style(debug#COMMA_DELIMITED)      ' Configure debug display
      debug.Start(115200)                     ' Start debug cog
    
      cognew(TimerMs, @stack)                 ' Launch timekeeping cog
    
      repeat
        longmove(@minutes, @m, 3)             ' Copy TimerMs vars
        debug.ListHome                        ' Display values
        debug.Vars(@m, String("| minutes, seconds, milliseconds"))
        debug.break
    
    PRI TimerMs
    
      t  := cnt                               ' Current clock counter
      dt := clkfreq/1000                      ' Ticks in 1 ms
    
      repeat                                  ' Infinite loop
        waitcnt(t+=dt)                        ' Wait for the next ms
        ms++                                  ' Add 1 to millisecond count
        if ms == 1000                         ' If milliseconds = 1000
          ms := 0                             '  Set milliseconds to 0
          s++                                 '  Increment seconds
        if s == 60                            ' if seconds = 60
          s := 0                              '  Set seconds to 0
          m++                                 '  Increment minutes
        if m == 60                            ' If minutes = 60
          m := 0                              '  Set minutes to 0
    
    
  • My initial attempts to use PST Lite weren't successful.

    I switched to Parallax Serial Terminal.spin and used a less elegant formatting technique to get the data to appear the way I wanted it.

    Sorry for not helping with the PST Lite but hopefully the example below will be useful.
    CON
      _clkmode = xtal1 + pll16x     'Crystal and PLL settings
      _xinfreq = 5_000_000          '5MHz crystal x 16 = 80MHz
    
    OBJ
    
      debug : "Parallax Serial Terminal" 'Serial communications object
    
    VAR
    
      long stack[40]                'Ample stack for prototyping
      long m, s, ms, t, dt          'Timekeeping variables
    
    PUB GO | minutes, seconds, milliseconds
    
      debug.Start(115200)           'Start Debug cog
    
      cognew(TimersMS, @stack)      'Start timekeeping cog
    
      
      {*** Comment out the code below to allow the program to immediately beginning timer. ***}
      repeat                        'Prompt to begin
        debug.Str(String(11, 13, "Press any key to begin."))
        waitcnt(clkfreq / 2 + cnt)
        result := debug.RxCount
      until result
    
      debug.RxFlush                 'Remove character used to begin program from buffer.
      {*** Comment out the code above to allow the program to immediately beginning timer. ***}
    
      
      repeat 
        longmove(@minutes, @m, 3)   'Copy TimerMS vars so all three are frozen in time together. 
        debug.Home              
        debug.ClearEnd              'Erase anything on the line.
        debug.NewLine
        debug.ClearEnd              'The method "ClearEnd" keeps the display area clean.                                  
        debug.NewLine
        debug.Str(string(" minutes = "))
        debug.dec(minutes)
        debug.Str(string(", seconds = "))
        debug.dec(seconds)
        debug.Str(string(", milliseconds = "))
        debug.dec(milliseconds)
        debug.ClearEnd              'Erase anything on the line after the text just written.   
        debug.NewLine               'The method "ClearEnd" solves problems caused with the new 
        debug.ClearEnd              'number has fewer digits than the previous number.  
        debug.NewLine               'Move to a new line prior to clearing text anything left on the screen.
        debug.ClearBelow            'Erase any undesired text under the newly written text.
        
    PRI TimersMS
    
      t := cnt                      'Current clock counter
      dt := clkfreq / 1000          'Ticks in 1 ms
    
      repeat                        'Infinat loop
        waitcnt(t += dt)            'Wait for the next ms
        ms++                        'Add 1 to millisecond count
        if ms == 1000               'If millisecond = 1000
          ms := 0                   'Set ms to 0
          s++                       'Incriment second
          if s == 60                'If second = 60
            s := 0                  'Set second to 0
            m++                     'Increment Minute
            if m == 60              'If m equals 60
              m:=0                  'Set minute to 0
    

    You had an indentation problem in the "TimerMS" method.

    The above code outputs the following text.
    
     minutes = 0, seconds = 9, milliseconds = 354
    
  • Thanks you for the right copy of "PST debug Lite" that made all the difference.

    And thanks for the indent info I saw that after I posted it.

    Blake
  • Is the PST debug only for windows? I don't find a mac version tho.
  • Now that I have the program working, I have a question about the code.
    PUB GO | minutes, seconds, milliseconds
    
      debug.Style(debug#COMMA_DELIMITED)
      debug.Start(115200)                                                                                   'Start Debug cog
    
      cognew(TimerMS, @stack)                                                                               'Start timekeeping cog
    
      repeat 
        longmove(@minutes, @m, 3)                                                                           'Copy TimerMS vars
        debug.ListHome                                                                                      'Display values
        debug.Vars(@m, String("| minutes, seconds, milliseconds"))                                          '
        debug.break
    

    The go method initializes three local variables (MINUTES, SECONDS, MILLISECONDS

    Q1) Is longmove and debugV.Vars the only place these variables used? I do not see them come up anywhere else in either Object.

    Q2) How does longmove migrate all three variables (m,s,ms) into all three new variables (minutes, seconds, milliseconds) when it Specifies one variable ( @m to copy to @minutes, 3 long of @m)?

    Thanks again.



  • Technically: If you are debugging spin, than clever use of serial(name as you want) .dec(), .hex(), .bin(), str(), and .tx() is enough.

    After load cell programming (1000 samples per second 12 bit data) I also like Serial plotter from Arduino IDE (compatible with propeller after some tricks) for data visualisation and Realterm to validate low level binary data to meet custom protocol specifications.

    ASM for advanced guys? That another story. I'd prefer PASD. It works fine with latest propeller tool on windows 7.
  • Blake Koch wrote: »
    Q2) How does longmove migrate all three variables (m,s,ms) into all three new variables (minutes, seconds, milliseconds) when it Specifies one variable ( @m to copy to @minutes, 3 long of @m)?

    Since the three variables are consecutive, they all three get moved together. The variables in both locations need to be consecutive in order to use longmove this way.

    I assume the method "Vars" assumes the variables are consecutive.

  • Thanks for description of how longmove moves consecutive variables. I kind of thought that, but wanted to be sure.

    Blake
  • The @ in front of the m means the address of m.
    So it is moving 3 longs that start at @m. When declaring vars, spin locates them consecutively in the order declared.

    Tom
  • Dave HeinDave Hein Posts: 6,347
    edited 2017-03-29 12:35
    twm47099 wrote: »
    When declaring vars, spin locates them consecutively in the order declared.
    In a VAR section, the order is maintained, but only in groups of the same size. The Spin compiler will group all long variables at the beginning of the VAR section, followed by all the word variables, and then followed by all the byte variables. In a DAT section, the variables are maintained in the order that they are declared, independent of the size.

  • Thanks this all help my knowledge of how to move these variable around.

    Blake
  • Publison wrote: »

    The links on that page result in "Page not found"
    Any other ideas as to where it might be?

    Thanks Mike
  • PublisonPublison Posts: 12,366
    edited 2019-01-24 20:43
    Mad_Mike wrote: »
    Publison wrote: »

    The links on that page result in "Page not found"
    Any other ideas as to where it might be?

    Thanks Mike

    Welcome to the forum! Not a good first experience. :)

    I'll alert the webmaster to fix the links.

    For the time being, I can offer this attachment.
  • Some more info can be gotten here:

    https://www.parallax.com/product/32305
Sign In or Register to comment.