Shop OBEX P1 Docs P2 Docs Learn Events
FlexProp: a complete programming system for P2 (and P1) - Page 23 — Parallax Forums

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

1202123252654

Comments

  • @deets said:
    I appreciate the insights. I read somewhere that spin is IRQ friendly - I guess that’s PNut then. Is there a way to safely store PASM and state somewhere? Or should I just declare spin state & it will be accessible?

    There is no way to support interrupts in FlexProp compiled code at this time. There's no mechanism for saving and restoring the state of the compiled code.

  • Good to know.

    Thanks to ManAtWork I was able to remove my blinking-COG and instead am using smartpin pulse mode now. However I'm flummoxed by a behavior I can't explain. The following is my spin:

    pri setup_pins()
      pinclear(conf.SYSTEM_STATUS_PIN)
      pinclear(conf.SD_STATUS_PIN)
      case system_status
        SYSTEM_IDLE: pinlow(conf.SYSTEM_STATUS_PIN)
        SYSTEM_CAPTURING: pinhigh(conf.SYSTEM_STATUS_PIN)
        SYSTEM_ERROR: pinstart(conf.SYSTEM_STATUS_PIN, P_PWM_SAWTOOTH+P_OE, 5000<<16+(clkfreq/10000), 2500)
      case sd_status
        SD_OK: pinlow(conf.SD_STATUS_PIN)
        SD_WRITING: pinhigh(conf.SD_STATUS_PIN)
        SD_ERROR: pinstart(conf.SD_STATUS_PIN, P_PWM_SAWTOOTH+P_OE, 5000<<16+(clkfreq/10000), 2500)
    

    I have two status-pins that can be off, on, or blinking. And that works just marvelous for the SD_STATUS_PIN. However the SYSTEM_STATUS_PIN that should switch from IDLE to CAPTURING and back to IDLE does not perform the last step. It stays high.

    Both are electrically setup the same way, LED + current limiting resistor.

    I tried making the case explicit, and DEBUGed the case branches, which worked as expected. The LED just doesn't fall dark.

    The following is the assembly generated, it looks reasonably similar for both cases to my untrained eye:

    _status_setup_pins
        mov COUNT_, #9
        call    #pushregs_
        fltl    #24
        wrpin   #0, #24
        mov arg01, #25
        fltl    #25
        wrpin   #0, #25
        rdbyte  local01, objptr
        fle local01, #3
        mov local02, local01
        jmprel  local02
    LR__0019
        jmp #LR__0020
        jmp #LR__0021
        jmp #LR__0022
        jmp #LR__0023
    LR__0020
        mov arg01, #24
        drvl    #24
        jmp #LR__0023
    LR__0021
        mov arg01, #24
        drvh    #24
        jmp #LR__0023
    LR__0022
        mov local03, #24
        mov local04, #82
        rdlong  muldiva_, #20
        mov muldivb_, ##10000
        call    #divide_
        mov local05, muldivb_
        mov local06, ##327680000
        add local06, local05
        mov local07, local06
        mov local08, ##2500
        mov arg01, local03
        mov arg02, local04
        mov arg03, local07
        mov arg04, ##2500
        dirl    arg01
        wrpin   arg02, arg01
        wxpin   arg03, arg01
        wypin   ##2500, arg01
        dirh    arg01
    LR__0023
        add objptr, #1
        rdbyte  local03, objptr
        sub objptr, #1
        mov local01, local03
        fle local01, #3
        mov local09, local01
        jmprel  local09
    LR__0024
        jmp #LR__0025
        jmp #LR__0026
        jmp #LR__0027
        jmp #LR__0028
    LR__0025
        drvl    #25
        jmp #LR__0028
    LR__0026
        drvh    #25
        jmp #LR__0028
    LR__0027
        mov local04, #25
        mov local06, #82
        rdlong  muldiva_, #20
        mov muldivb_, ##10000
        call    #divide_
        mov arg03, ##327680000
        add arg03, muldivb_
        mov arg01, local04
        mov arg02, local06
        dirl    arg01
        wrpin   arg02, arg01
        wxpin   arg03, arg01
        wypin   ##2500, arg01
        dirh    arg01
    LR__0028
        mov ptra, fp
        call    #popregs_
    _status_setup_pins_ret
        ret
    

    Any suggestions?

  • brewmaxwell649brewmaxwell649 Posts: 1
    edited 2021-10-21 08:46

    Got it. Worked with my Rev b out of the box first time.

    Mobdro

  • @deets : are you sure that the system_status variable is in fact being set back to SYSTEM_IDLE at the appropriate time? And that it's staying in that state?

    Also, you might consider commenting out the pinclear() calls; they're redundant I think.

  • @ersmith I am sure, I did use an if cascade & debug-printed the case. It entered the correct one. I’ll check if the pinclear is needed. However there is the weird behavior difference to the SD card pin 🤔

  • Here's a test program that shows the setup_pins() function is working fine -- it responds correctly to any combination of settings I enter on the terminal. So I don't think your problem lies there, it must be somewhere else in your program.

    CON
      _clkfreq = 180_000_000
      SYSTEM_STATUS_PIN = 58
      SD_STATUS_PIN = 56
      #0, SYSTEM_IDLE, SYSTEM_CAPTURING, SYSTEM_ERROR
      #0, SD_OK, SD_WRITING, SD_ERROR
    
    OBJ
      ser: "jm_serial"
    
    VAR
      byte system_status
      byte sd_status
    
    pub main() | a, b
      ser.start(230_400)
      repeat
        setup_pins()
        ser.str(string("Enter 2 characters for state of SD and system: ", 13, 10))
        ser.str(string("0 for idle/ok, 1 for capturing/WRITING, anything else for ERROR", 13, 10))
        ser.str(string("> "))
        a := ser.rx()
        ser.tx(a)
        b := ser.rx()
        ser.tx(b)
        ser.tx(13)
        ser.tx(10)
        if a == "0"
          system_status := SYSTEM_IDLE
        else
          system_status := (a == "1") ? SYSTEM_CAPTURING : SYSTEM_ERROR
        if b == "0"
          sd_status := SD_OK
        else
          sd_status := (b == "1") ? SD_WRITING : SD_ERROR
    
    pri setup_pins()
      pinclear(SYSTEM_STATUS_PIN)
      pinclear(SD_STATUS_PIN)
      case system_status
        SYSTEM_IDLE: pinlow(SYSTEM_STATUS_PIN)
        SYSTEM_CAPTURING: pinhigh(SYSTEM_STATUS_PIN)
        SYSTEM_ERROR: pinstart(SYSTEM_STATUS_PIN, P_PWM_SAWTOOTH+P_OE, 5000<<16+(clkfreq/10000), 2500)
      case sd_status
        SD_OK: pinlow(SD_STATUS_PIN)
        SD_WRITING: pinhigh(SD_STATUS_PIN)
        SD_ERROR: pinstart(SD_STATUS_PIN, P_PWM_SAWTOOTH+P_OE, 5000<<16+(clkfreq/10000), 2500)
    
    
  • RaymanRayman Posts: 13,797

    @ersmith Is spin2cpp considered part of FlexProp?

    Have a question about what it does if the constant "_clkfreq" is defined, but not sure where to ask...
    I believe it's just being ignored, but not really sure...

  • @Rayman said:
    @ersmith Is spin2cpp considered part of FlexProp?

    Not really. It's related to FlexSpin (uses the same libraries) but isn't included in FlexProp.

    Have a question about what it does if the constant "_clkfreq" is defined, but not sure where to ask...
    I believe it's just being ignored, but not really sure...

    On P2 it's just being ignored. On P1 it outputs some PropGCC specific defines to set the clock frequency, but those are protected by #ifdef and will be ignored on Catalina.

    I think the most common use case for spin2cpp is for converting drivers, and ignoring _clkfreq seems reasonable for this.

  • RaymanRayman Posts: 13,797

    @ersmith It appears that the enum way of setting the P2 clock frequency no longer works...

  • @Rayman said:
    @ersmith It appears that the enum way of setting the P2 clock frequency no longer works...

    It works for me:

    $ cat foo.c
    #include <stdio.h>
    #include <propeller2.h>
    
    enum {
        _clkfreq = 210_000_000
    };
    
    int main() {
        printf("clock frequency is: %u\n", _clockfreq());
    }
    $ flexspin -2 foo.c
    Propeller Spin/PASM Compiler 'FlexSpin' (c) 2011-2021 Total Spectrum Software Inc.
    Version 5.9.4-beta-v5.9.3-28-gf467ec1e Compiled on: Oct 19 2021
    foo.c
    fmt.c
    foo.p2asm
    Done.
    Program size is 3768 bytes
    $ loadp2 foo.binary -b230400 -t
    ( Entering terminal mode.  Press Ctrl-] or Ctrl-Z to exit. )
    clock frequency is: 210000000
    
  • RaymanRayman Posts: 13,797

    Pls try with this enum before that one:
    //override the default heapsize
    enum { heapsize = 8000 };

  • @Rayman : that's a weird bug! For now you can work around it by putting the two constants into the same enum.

  • pik33pik33 Posts: 2,347

    The new Flexprop cannot run SimpleSound demo by Ahle2. It compiles and run, but it gives no audio. The same SimpleSound compiled using Flexprop 5.3.1 version works and plays music - 5.5.1 and later are silent

  • pik33pik33 Posts: 2,347

    Another strange UI problem in 5.9.3 Windows: I cannot detect and select a serial port as in earlier versions. "Find port automatically" can not be unselected. A bug or a feature?

  • RaymanRayman Posts: 13,797
    edited 2021-10-21 15:34

    I'm also seeing SimpleSound not working any more.
    This might be a tough one to trouble shoot as it's a bit big...
    It does work with version 5.4.3, broke with 5.5.2

    My wave player still works...

  • RaymanRayman Posts: 13,797
    edited 2021-10-21 20:10

    Looks like it's between 5.5.0 and 5.5.1 when SimpleSound stopped working..

    Original Spin2 version still works with Prop Tool, but not FlexProp...

  • It looks like the change in 5.5.1 to move all objects until after the other member variables may have broken SimpleSound.

    Here's a version of flexspin that reverts that change. Could someone give it a try and see if it fixes the problem?

  • RaymanRayman Posts: 13,797

    Tried, but getting this:
    1>EXEC : error : No implementation for __lockio' found inlibsys/fmt.c'
    1>EXEC : error : No implementation for __unlockio' found inlibsys/fmt.c'

  • pik33pik33 Posts: 2,347

    Windows Defender didn't allow me to unpack the zip.

    Trojan:Win32/Wacatac.B!ml

  • @Rayman : I'm surprised __lockio would come up for any Spin2 program. Did you have debugging enabled, perhaps?

    @pik33 : I built the executable on Linux with a cross-compiler, so it's highly unlikely indeed to have been infected with a Windows virus.

  • RaymanRayman Posts: 13,797

    @ersmith This was the C version with Spin2 drivers... What is _lockio anyway?

  • RaymanRayman Posts: 13,797

    Ok, the new FlexSpin does work with the Spin2 version of SimpleSound

  • pik33pik33 Posts: 2,347

    Maybe it is Defender's oversensibility - I noticed such oversensibility earlier - but I cannot do anything with the file.

  • RaymanRayman Posts: 13,797
    edited 2021-10-23 20:56

    Here's the file Ok, that won't help...
    Maybe use a different browser?
    Edge complained about the file for me, but I was able to get it after clicking on "more info" or something like that...

    Update: Actually it now says "can't download, virus detected" for me too... What a pain...

    I think Eric can sign the actual release and this problem will go away...

  • pik33pik33 Posts: 2,347

    Now if the changed compiler worked with Simple Sound, maybe a change in the Simple Sound can be made to make it work again.

    Why this

    move all objects until after the other member variables

    caused a problem in it?

  • My longwinded method is to download/unpack to my Android phone and transfer the files via Bluetooth. :)

  • pik33pik33 Posts: 2,347

    @Mickster said:
    My longwinded method is to download/unpack to my Android phone and transfer the files via Bluetooth. :)

    This cannot help in this case as the Defender deletes the file as soon as it detects it. Unsip->quarantine-remove from quarantine-try to run-quarantine.
    Now this is not important anymore, as

    @Rayman said:
    Ok, the new FlexSpin does work with the Spin2 version of SimpleSound

    and we can remove the test compiler and not use it anymore

    This means there is something in SimpleSound which is not compatible with the new Flexspin and it is SimpleSound where we have to find it. Then:

    • if this is a bug in SimpleSound which is unnoticed earlier, as it worked, correct the bug in SimpleSound
    • if this is a bug in the compiler, correct the compiler
  • The new/current flexspin behavior is/should-be the same as PNut/Proptool.... Has anyone tried it there?

  • Reverting the variable/object reordering change is certainly not the right solution (and will totally mess up code density for bytecode mode)

  • RaymanRayman Posts: 13,797
    edited 2021-10-24 15:47

    Yes, simple sound works with PropTool still

Sign In or Register to comment.