Shop Learn
FlexProp: a complete programming system for P2 (and P1) - Page 17 — Parallax Forums

FlexProp: a complete programming system for P2 (and P1)

1111213141517»

Comments

  • SuracSurac Posts: 147

    Hello
    i have found something and i am not sure if it is indented behavior. If I have a code like:

    con 
        _clkfreq=100_000_000
    
    dat
       org 
        rep @done,#0
        drvnot #0
    done
    

    If I compile it with PNUT it knows about the 100MHz set in the con block and the P2 is indeed running with 100MHz after downloading to ram via PNUT

    But if I compile and download it with FlexProp the _clkfreq=100MHz gets ignored. In the List file there is no sign of setting the clock. P2 is still in RCFAST mode after downloading

    I Know i can set the clock manually. But i wonder if this is indented.

  • ersmithersmith Posts: 4,853

    @Surac said:
    Hello
    i have found something and i am not sure if it is indented behavior. If I have a code like:

    con 
      _clkfreq=100_000_000
    
    dat
       org 
      rep @done,#0
      drvnot #0
    done
    

    If I compile it with PNUT it knows about the 100MHz set in the con block and the P2 is indeed running with 100MHz after downloading to ram via PNUT

    Please check again, I don't think PNut does this. I get the exact same 8 byte binary when I compile your sample program with flexspin and with PNut. If there are no Spin methods, then the Spin setup code (in flexprop) or Spin interpreter (in PNut) is not included, so the clock is not set. In order to set the clock in an assembly only program, use the ASMCLK macro.

  • SuracSurac Posts: 147
    edited 2021-03-30 18:48

    I can confirm it works like i said.

    this is what pnut outputs as .lst file. as you can see it knows the 100MHz BUT in the .obj or .bin file there is no sign of any clock initialisation. I think PNUT uses features of the bootloader to set the clock frequency. It may be an inconsistent behavior of PNUT because it is useless if it is not in the .bin file.

    TYPE: CON             VALUE: 05F5E100          NAME: _CLKFREQ
    TYPE: CON             VALUE: 0100090B          NAME: CLKMODE_
    TYPE: CON             VALUE: 05F5E100          NAME: CLKFREQ_
    TYPE: DAT_LONG        VALUE: 00200008          NAME: DONE
    
    
    CLKMODE:   $0100090B
    CLKFREQ: 100,000,000
    XINFREQ:  20,000,000
    
    
    Hub bytes:           8
    
    00000- 00 02 DC FC 5F 00 64 FD                           '...._.d.'
    

    neverminded this is a 'feature' one cannot rely on as it only works while downloading via PNUT. In fact, this is quite dangerous as it is unexpected.

  • SuracSurac Posts: 147

    Hello. Me again :smile:

    Today i tried the integration between Flexprop and VSCODE. It works nice but i have one little concern that isn't related directly with VSCODE, but makes using VSCODE a bit messy.

    • Downloading the .binary file is done with loadp2. VSCODE opens a shell and starts loadp2.exe with some command line parameters. Easy enough.
    • loadp2 offers to open a terminal after the download. To exit the terminal, you must press CRTL-]. This may be true on a US layout keyboard. But not on my german layout keyboard.
    • After searching some time i found i have to press CTRL-+ (plus key) to exit the terminal. On a German Keyboard [ ] are not available without pressing a modifier key. The + Key on a German keyboard is where the ] key is on an US keyboard.
    • This will all work ok if i use loadp2 directly from the shell (i only have to remember that crtl-] translates to ctrl-+). But in VSCODE the ctrl-+ Key is already catched by VSCODE itself. it is used to scale the VSCODE gui up.

    It will be nice to have a command line switch to change the exit shortcut of the terminal somehow. ctrl-] ist only good on US layout keyboards.

    a second inconvenience is that if i do not use the terminal loadp2 always asks to press the enter key to exit. Is there a kind of commandline switch to just download the .binary and not wait for enter key afterwards?

  • roglohrogloh Posts: 3,116

    Yes Surac I think it is the -k switch in loadp2 doing it. Disable that command line switch.

  • roglohrogloh Posts: 3,116
    edited 2021-04-01 15:57

    You can also issue the byte sequence 255, 0, 0 out the serial port from the P2 to exit from the loadp2 terminal on the PC which can be very handy.

  • SuracSurac Posts: 147

    @rogloh said:
    Yes Surac I think it is the -k switch in loadp2 doing it. Disable that command line switch.

    Nice that cured my second inconvenience.

  • Cluso99Cluso99 Posts: 17,666

    @Surac said:
    Hello. Me again :smile:

    Today i tried the integration between Flexprop and VSCODE. It works nice but i have one little concern that isn't related directly with VSCODE, but makes using VSCODE a bit messy.

    • Downloading the .binary file is done with loadp2. VSCODE opens a shell and starts loadp2.exe with some command line parameters. Easy enough.
    • loadp2 offers to open a terminal after the download. To exit the terminal, you must press CRTL-]. This may be true on a US layout keyboard. But not on my german layout keyboard.
    • After searching some time i found i have to press CTRL-+ (plus key) to exit the terminal. On a German Keyboard [ ] are not available without pressing a modifier key. The + Key on a German keyboard is where the ] key is on an US keyboard.
    • This will all work ok if i use loadp2 directly from the shell (i only have to remember that crtl-] translates to ctrl-+). But in VSCODE the ctrl-+ Key is already catched by VSCODE itself. it is used to scale the VSCODE gui up.

    It will be nice to have a command line switch to change the exit shortcut of the terminal somehow. ctrl-] ist only good on US layout keyboards.

    a second inconvenience is that if i do not use the terminal loadp2 always asks to press the enter key to exit. Is there a kind of commandline switch to just download the .binary and not wait for enter key afterwards?

    As I read, I was horrified when you said Ctrl+ until I read further.

    I cannot believe we’re close to 40 years since the PC arrived, and we haven’t solved fundamental problems such as PC/*nix/Mac crlf problems and basic control sequences and keyboard layouts for even the major countries. I guess if we cannot resolve a standard keyboard layout for the English speaking countries (US, UK, AU comes to mind) what hope have we to fix this deeper problem.

    @Surac, I feel your pain as I’ve not realised the additional problems non-English-speaking countries have with just these basics.

  • ersmithersmith Posts: 4,853

    @Surac: I will add Control-Z as another way to leave the loadp2 program in the next release. Closing the window should also work (does VSCODE give that option?)

  • SuracSurac Posts: 147
    edited 2021-04-02 08:58

    Hello,

    VSCode does not open a shell window but uses the shell embedded in the GUI in a Dock. IT is a single window application so there is no easy way to close the terminal, except using what the terminal offers.

    i checked Ctrl-Z and it gives a 26 = 0x1A on my German keyboard. Ctrl-A to Ctrl-Z is translated to 1-26 :smile:

    EDIT:

    • i have digged into the source code of load2p terminal function and found you are reading the keyboard using getch().
    • getch() returns keyboard scan codes, so they are platform specific (and keyboard specific) and returns a 16 bit value
    • Scancodes are "near" ascii but only for letters and numbers.
    • So, the scan code is not depending on the symbol printed on the key but the position of the key on the keyboard. however normal letters and numbers are "changed" to reflect the actual language of the keyboard (very confusing but that's why ctrl-z works and ctrl-] not)
  • @Surac said:
    Hello,

    VSCode does not open a shell window but uses the shell embedded in the GUI in a Dock. IT is a single window application so there is no easy way to close the terminal, except using what the terminal offers.

    You can kill the terminal session. Just click the trashcan icon.

  • SuracSurac Posts: 147

    @Wuerfel_21 said:
    You can kill the terminal session. Just click the trashcan icon.

    oh. i was not able to see it :smile: Thank you so much. But having ctrl-z will be perfect anyway

  • ersmithersmith Posts: 4,853

    The new version of flexprop (5.3.2) is on my Patreon page now. I plan to make a github binary release this weekend.

  • SuracSurac Posts: 147

    Giving this Program:

    CON
            _clkfreq = 10_000_000
    
    DAT     
            org $0      
            asmclk
            call #\sub1
            call #\sub2          'here it tries to call #$40 = fatal. Also fails if using call #sub2 (relativ call)
    
    ende    jmp #ende         'funny: in Flexspin end is a good lable name. in PNUT end is no good lable name. So i use ende here   
    
    sub1    dirh #56
            ret 
    
            org $40          'here is the question relevant part
    
    sub2
            dirh #57
            ret
    

    This program compiles with no error in FLEXSPIN and PNUT but does not work in both

    in Flexspin:

    • lst. file shows that sub2 is calculated to be $40 but there is no code
    • sub2 is placed directly behind sub1. it seems the org $40 is obeyed for calculating offsets but not for code generation
    • using orgf $40 instead of org $40 works as intended in FLEXSPIN and PNUT

    • shouldn't there be a compiler warning for using org with address or using org twice?

    • is org even intended to be used with an address != 0?
  • roglohrogloh Posts: 3,116

    There are times when you want to generate code that isn't padded out, in case you intend to load things directly to the ORG'd address later, from HUB into COG RAM. So you can certainly use ORG with a COG address and/or multiple times in the DAT section.

    In this case the compiler is just doing what you tell it. No warning is needed. You just need to know that ORG will not pad by default and you need to use ORGF instead if you wanted to pad it.

  • SuracSurac Posts: 147

    Jep - makes sense
    org only manages lable und jump addresses, not code layout

  • ersmithersmith Posts: 4,853

    The binary version of Flexprop 5.3.2 is available now from github. This is mainly a bug fix release, although it does have new versions of loadp2 and proploader which accept Control-Z for closing the window alongside Control-].

  • There seems to be some issues with the serial driver. While typing in on the terminal session sometimes I get a question mark, ?, and sometimes the letter does not take.

    I can load a file with no issues it's just when typing.

    Mike

  • ersmithersmith Posts: 4,853

    @iseries said:
    There seems to be some issues with the serial driver. While typing in on the terminal session sometimes I get a question mark, ?, and sometimes the letter does not take.

    I can load a file with no issues it's just when typing.

    Mike

    On which platform (P1 or P2)? Which terminal are you using? Which language(s)?

  • Never mind, I'm on the P2 with a WiFi module in-between. I tried it with just the prop plug and it works just fine. Must be something with the telnet session.

    Mike

  • RamonRamon Posts: 464

    @ersmith said:
    @evanh : DEBUG() statements are optional (as they are in PNut). In order to enable debug() flexspin needs the -g flag on the command line. We should probably continue this on the flexspin thread if you have more questions.

    Hi Eric, I have noticed that PORT BAUD is doubled automatically after adding '-g' on flexspin 'Commands> Configure Commands> Compile Command".

  • ersmithersmith Posts: 4,853

    @Ramon said:

    @ersmith said:
    @evanh : DEBUG() statements are optional (as they are in PNut). In order to enable debug() flexspin needs the -g flag on the command line. We should probably continue this on the flexspin thread if you have more questions.

    Hi Eric, I have noticed that PORT BAUD is doubled automatically after adding '-g' on flexspin 'Commands> Configure Commands> Compile Command".

    I'm not able to reproduce any problem like this. What do you mean exactly by "PORT BAUD" is doubled? Do you mean that the -D_BAUD=xxx parameter appears twice on the command line? Or do you mean that the value for the baud is increased? How did you add the -g, did you use the "Debug Enabled" option in the Option menu, or did you edit the command yourself?

    Regards,

  • RamonRamon Posts: 464

    I am using latest version 5.3.2 (on W10). I usually run program code at 115_200 BAUD, and after adding the -g option the BAUD is increased to 230_400.

    I directly added '-g' on "Commands> Configure Commands> Compile Command". That was because the debug output was not working (the debug output didn't show any characters). Now, that I have check again I have found that the "Debug Enabled" was already enabled (didn't remember that I have that option enabled).

    Don't spend too much time looking at this. The debug is working, and using 230_400 BAUD is also OK.

    The code I was testing is this one: (when I use Ports > 115_200 baud output show garbage; characters only works well at 230_400; and what surprised me was that the BAUD speed was automatically adjusted by the GUI)

    CON
      _clkfreq  =  200_000_000
      rx_pin   = 63
      tx_pin   = 62
      baud     = 115_200
      DOWNLOAD_BAUD = 115_200
      DEBUG_DELAY = 100
      DEBUG_BAUD = 115_200
    
      MSR_PIN   =  0    {connected to pin 0}
    
    OBJ
      ser: "spin/SmartSerial"
    
    PUB main() | ticks, periods, freq, mintime
    
      ser.start(rx_pin, tx_pin, 0, baud)
      pinstart(39, P_NCO_FREQ+P_OE, 1, 1_000_150 frac clkfreq)   'test freq
      'pinstart(MSR_PIN, P_NCO_FREQ+P_OE, 1, (1_000_150<<32) / clkfreq)   'test freq
    
      mintime := clkfreq / 1_000             '1ms min measure time
      pinstart(MSR_PIN+0, P_COUNTER_TICKS, mintime, %00)
      pinstart(MSR_PIN+1, P_MINUS1_A + P_MINUS1_B + P_COUNTER_PERIODS, mintime, %00)
    
      repeat 
        'akpin(MSR_PIN addpins 1)              'start next measurement
        akpin( (MSR_PIN & $3F) | (1 & $1F) << 6)
        repeat until pinr(MSR_PIN)            'wait until done
        ticks   := rqpin(MSR_PIN+0)           'read measured values
        periods := rqpin(MSR_PIN+1)
        freq := muldiv64(clkfreq, periods, ticks-1)     'calc frequency
    
        debug(udec(ticks), udec(periods), udec(freq))
        'ser.printf("ticks: %u periods: %u  freq: %u \n", ticks, periods, freq)
    
        waitms(300)
    
    

    Compile log (at 115_200):

    "D:/P2/flexprop5.3.2/flexprop/bin/flexspin" -g -2 -l -D_BAUD=115200 -O1    -I "D:/P2/flexprop/include"  "D:/P2/flexprop/samples/frequency_counter_ariba_flexprop.spin2"
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.3.2 Compiled on: Apr  2 2021
    frequency_counter_ariba_flexprop.spin2
    |-SmartSerial.spin
    fmt.c
    posixio.c
    bufio.c
    errno.c
    frequency_counter_ariba_flexprop.p2asm
    Done.
    Program size is 14748 bytes
    Finished at Sat Apr 10 20:18:55 2021
    cmd.exe /c start "Propeller Output  " "D:/P2/flexprop5.3.2/flexprop/bin/loadp2"  -b115200 "D:/P2/flexprop/samples/frequency_counter_ariba_flexprop.binary" "-9D:/P2/flexprop/samples" -k
    
    

    Compile log (at 230_400)

    "D:/P2/flexprop5.3.2/flexprop/bin/flexspin" -g -2 -l -D_BAUD=230400 -O1    -I "D:/P2/flexprop/include"  "D:/P2/flexprop/samples/frequency_counter_ariba_flexprop.spin2"
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.3.2 Compiled on: Apr  2 2021
    frequency_counter_ariba_flexprop.spin2
    |-SmartSerial.spin
    fmt.c
    posixio.c
    bufio.c
    errno.c
    frequency_counter_ariba_flexprop.p2asm
    Done.
    Program size is 14748 bytes
    Finished at Sat Apr 10 20:24:16 2021
    cmd.exe /c start "Propeller Output  " "D:/P2/flexprop5.3.2/flexprop/bin/loadp2"  -b230400 "D:/P2/flexprop/samples/frequency_counter_ariba_flexprop.binary" "-9D:/P2/flexprop/samples" -k
    
  • RaymanRayman Posts: 11,932
    edited 2021-04-10 12:33

    I seem to remember debug only works at 230400 baud too.

    It’s fine, just something to know.

  • pik33pik33 Posts: 992
    edited 2021-04-10 17:07

    I had another problem, which I cannot now reproduce, so maybe it was a glitch.

    I used TAB instead of spaces while writing the spin2 code. The code didn't run as expected until I noticed this and replaced these tabs with proper amount of spaces.

    Using Lazarus IDE for any other programming I simply (uncounsciously) expected the same behaviour (tab key inserts several spaces to the code and not a "tab" ascii code)

    Then I tried to repeat the error, but this time the code didn't want to fail. :) Still... better avoid the TAB key.


    Edit: another glitch" comments are not always grayed out. Add a space or something to the line and the comment is gray again. This is the glitch I cannot reproduce at will, too.

  • Cluso99Cluso99 Posts: 17,666

    @pik33 said:
    I had another problem, which I cannot now reproduce, so maybe it was a glitch.

    I used TAB instead of spaces while writing the spin2 code. The code didn't run as expected until I noticed this and replaced these tabs with proper amount of spaces.

    Using Lazarus IDE for any other programming I simply (uncounsciously) expected the same behaviour (tab key inserts several spaces to the code and not a "tab" ascii code)

    Then I tried to repeat the error, but this time the code didn't want to fail. :) Still... better avoid the TAB key.


    Edit: another glitch" comments are not always grayed out. Add a space or something to the line and the comment is gray again. This is the glitch I cannot reproduce at will, too.

    Or use VSCode with spaces set instead of tabs.

Sign In or Register to comment.