Announcement

Collapse
No announcement yet.

OVF() not always right?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • OVF() not always right?

    Greatings,

    I'm trying to calculate the rms voltage of a signal and need to add the square of a bunch of adc samples.
    This will create numbers bigger than 0xffff so i tried to use the ovf() function but is dose not seem to always work.

    var loWord, hiWord;
    loWord := 0x2710 * 0x8710; // (10000 * 10000 in hex format)
    hiWord := OVF();
    txt_MoveCursor(line++,1);
    print ("0x", [HEX] hiWord, [HEX] loWord);

    This will print 0xed8be100 but must be 0x149BE100.

    The original example with 0x2710^2 dose give the right awnser.

    Hope somone can help.

    PS: if anyone knowes a way to speed up the i2c past 1mhz to 1.7 plz let me know.

  • #2


    A straight multiply is signed, sothe answer you are getting is correct.

    For an unsigned multiply look at





    umul_1616

    in the manual.

    1mhz is the max I2C speed
    Mark

    Comment

    Working...
    X