Compller CON internal 32bit calculations ?
Phillip Y.
Posts: 62
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.
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 Williams
Applications Engineer, Parallax
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.