Shop OBEX P1 Docs P2 Docs Learn Events
P2 template in Prop Tool bug/feature — Parallax Forums

P2 template in Prop Tool bug/feature

Just downloaded the 2.7.0 PropTool beta hoping this was fixed but seems not...

When you pick File-> New (From P2 Template) it won't compile because it's in P1 mode.
It should put itself in P2 mode and show "P2:" on the file tab.
Instead, it doesn't say if P1 or P2 mode, but seems to always be P1 mode.

This seems to be a bug to me and would confuse new users.

Comments

  • RaymanRayman Posts: 14,646
    edited 2022-06-10 21:30

    Also, it would be nice if the template could be something that actually compiles...
    Have an object from the library in the OBJ section or comment it out.

    Also, be good to specify clock frequency there.

    Personally, I'd rename "public_method_name()" to "Main()" and probably but a repeat there.

  • JonnyMacJonnyMac Posts: 9,104
    edited 2022-06-11 02:30

    I have provided my template to Parallax many times -- the only person who use it is Ken.

    This is an observation, not a criticism, but the people who build tools at Parallax don't actually do anything meaningful with the Propeller (1 or 2). It's not that the wouldn't if they had time, but they're a very small, over-worked team the Ken worked very hard to keep together the last couple of years with COVID and all the red tape (especially here in CA) forced onto businesses.

    My latest template is attached. It has my serial and random libraries included. Since I'm providing an archive, you know it compiles -- after you've saved it as a Spin2 file.

    Propeller Tool needs a lot of finishing touches (it has since released), but what I really miss now is being able to compile without saving. That is the purpose of the {$P2} comment tag. Jeff uses tags like this in the BASIC Stamp Editor, and I'm hoping he will incorporate that in Propeller Tool as well.

    Whoops.... I had stuffed a little test code into my template; that's cleaned out of this version. This is where it would be nice to compile without having to save.

  • RaymanRayman Posts: 14,646

    That's not bad. I'd simplify it and add some comments like this:

  • evanhevanh Posts: 15,916

    Clock set options:

    con { timing }
    '  Set the clock setup suited to PCB/application:
    '  Template is preconfigured to 200 MHz PLL active from a 20 MHz crystal - suited for Prop2 Eval Board
    
    '  _rcfast
    '  _rcslow
    '  _xinfreq = 20_000_000                                         ' external oscillator frequency as a constant
      _xtlfreq = 20_000_000                                         ' crystal oscillator frequency as a constant
      _clkfreq = 200_000_000                                        ' system freq as a constant
    
      MS_001   = _clkfreq / 1_000                                   ' ticks in 1ms
      US_001   = _clkfreq / 1_000_000                               ' ticks in 1us
    

    Note I've got fully configured rather than assuming a 20 MHz crystal in use.

  • RaymanRayman Posts: 14,646

    How to start program and then shift to serial terminal in time to catch everything is still an issue.
    For the template, maybe something like this is a good way to handle that:

      'Start serial comms and then wait up to 10 seconds for terminal keypress, then continue
      ser.tstart(baud)    'start serial
      repeat i from 10 to 0 'wait up to 10 seconds
        ser.str(string("Press any key to skip count down: ")) 'tell user to press a key to avoid waiting
        ser.dec(i) 'show count down
        ser.str(string(" seconds until starting.", 13))
        waitms(1000) 'wait a second
        if ser.rxcheck() >= 0 'any key pressed
          ser.rxflush() 'remove all key presses from input buffer
          quit      'continue
    
  • In my templates I call this function right after all the IO and objects are setup:

      wait_for_terminal(true)
    

    This lets me open the terminal of my choice (usually PST, but sometimes PuTTY), enable it, press and key and go. Easy-peasy. The code works with PST and ANSI (if defined) terminals. I prefer to put this code away in functions to keep the main() method cleaner.

    pub wait_for_terminal(clear)
    
    '' Wait for terminal to be open and key pressed
    
      term.rxflush()
      term.rx()
      if (clear)
        clear_screen()
    
    
    pub clear_screen()
    
      if (T_TYPE == T_PST)
        term.tx(term.CLS)
      else
        term.str(ansi.hide_cursor())
        term.str(ansi.home())
        term.str(ansi.cls())
    
Sign In or Register to comment.