Shop OBEX P1 Docs P2 Docs Learn Events
Compller CON internal 32bit calculations ? — Parallax Forums

Compller CON internal 32bit calculations ?

Phillip Y.Phillip Y. Posts: 62
edited 2006-05-11 01:39 in Propeller 1
Aparently the compiler only uses·SIGNED 32 bit integers,
in this example to blink a led with OnTime and OffTime.

CON······························ ' evaluated in the compiler NOT the Propeller chip.
·Duty = 50······················· ' ON %
·Period = 42_949_672··············' period for blinking
································· ' with 50% duty 42_949_673·or more fails w led on
································· ' period * duty = 2,147,483,600 , ready to overflow
·OnTime· = ( Period * Duty) / 100 ' trouble if OnTime overflows and looks negatve
·OffTime = Period - OnTime······· '·

Period*duty is good for the full 32 bits because * is realy multiply low page4-106.
The / 100 of an overflowed number has unusable results.
This would work better if unsigned integers were avalible for the internal compiler calculations,
or more than 32 bits could be used.

Also there is no·way to·VIEW the evaluated·constants, or compiler output listing,
and·interpereting the HEX listing is a bit difficult.

Got any ideas ?

Phillip y.

Comments

  • Jon WilliamsJon Williams Posts: 6,491
    edited 2006-05-10 22:26
    Once you've compiled a file (with F8) you can click on a constant and its value will be displayed at the bottom of the IDE window (highlighted in yellow).

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Jon Williams
    Applications Engineer, Parallax
  • Phillip Y.Phillip Y. Posts: 62
    edited 2006-05-11 01:39
    Thanks Jon,
    Now I can see the actual results and figure things out faster,
    but making calculations to the upper 31/32bit limits looks like trouble.

    I have succeeded in getting a 1 to 99 % duty cycle led,
    that has a period of FFFF_FFFF = ~ 55 seconds.
    All calculations are done in the compiler to be able·to view the values,
    they would be unavailable if the propeller did the calculations.
    Program is attached.

    Phillip Y.
Sign In or Register to comment.