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

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

1545556575860»

Comments

  • Could it be that the function __builtin_frac is not implemented although it is in the documentation (c.pdf)? I get an error "unknown identifier _builtin_frac used in function call" when trying to do something like

        _pinstart (pinDrClk, MODE_DRCLK, 1, __builtin_frac(FREQ_DRCLK, CLK_FREQ));
    

    Do I need to #include something else additionally to "propeller2.h" to make it work?

  • ersmithersmith Posts: 6,194

    __builtin_frac was supposed to be a builtin keyword to C, but somehow it's missing from the C keywords table. I will fix that in the next release (it's fixed in github now). Thanks for catching this!

    In the meantime you can work around this by defining a function like:

    unsigned myfrac(unsigned a, unsigned b) {
        unsigned r = 0;
        __asm {
            setq a
            qdiv r, b
            getqx r
        }
        return r;
    }
    

    which should usually expand to the same code as the builtin, at least on P2 (the builtin will also work in some other environments).

Sign In or Register to comment.