Git Product home page Git Product logo

Comments (2)

pwittich avatar pwittich commented on August 17, 2024

Looking at the assembly output it looks like the compiler does not reduce this to 1/6000.

        bl      xTaskGetTickCount
        mov     r2, r0
        mov     r3, #1000
        mul     r3, r3, r2
        .loc 1 1116 14
        ldr     r2, .L354
        umull   r2, r3, r2, r3
        lsrs    r3, r3, #19

So we have an explicit multiplication by 1000 and then a division by a constant. The value stored at L354 is 375299969, so the umul followed by the shift corresponds to a multiplication of 1/5999999.999161332198245, i.e., 1/6e6.

from cm_mcu.

pwittich avatar pwittich commented on August 17, 2024

If I change the code in question to the following instead

  TickType_t now = xTaskGetTickCount()/(configTICK_RATE_HZ*60); // time in minutes

the generated assembly is now

        bl      xTaskGetTickCount
        mov     r2, r0
        .loc 1 1115 14
        ldr     r3, .L354
        umull   r2, r3, r3, r2
        lsrs    r3, r3, #7

where the value at 354 is now 91625969, which with the shift corresponds to multiplication by 1/6000.

from cm_mcu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.