Results vary between different versions of compilation and execution.

Robbert Lee
Robbert Lee Altair Community Member
edited December 2023 in Community Q&A

I use a simple interrupt to calculate the time difference. It works correctly and displays results in version 2022.3. However, when I compile the .c file in version 2023, there are some differences, and the execution shows incorrect results. How can I resolve this issue? (Arduino vision : 1.8.12)

image

Best Answer

  • pdarnell
    pdarnell
    Altair Employee
    edited December 2023 Answer ✓

    Hi Robbert, as your code above shows, the problem was the introduction of a temp variable that holds the T2-T1 difference before T2 gets assigned the micros() result. This is due to a change that was made to the use count analysis in the code generator where an auto inserted convert between the fixed point sum and the integer long External Write to deltaT block got counted as a use in addition to the Extern Write block itself.  Normally temp introduction does not affect code results, but obviously in this case it does. This will be fixed in the next update, but you can work around it by changing the type of the Extern Write to be the same scaledInt type as the sum output (fx32.32). Then no convert will be required.

    image

Answers

  • pdarnell
    pdarnell
    Altair Employee
    edited December 2023 Answer ✓

    Hi Robbert, as your code above shows, the problem was the introduction of a temp variable that holds the T2-T1 difference before T2 gets assigned the micros() result. This is due to a change that was made to the use count analysis in the code generator where an auto inserted convert between the fixed point sum and the integer long External Write to deltaT block got counted as a use in addition to the Extern Write block itself.  Normally temp introduction does not affect code results, but obviously in this case it does. This will be fixed in the next update, but you can work around it by changing the type of the Extern Write to be the same scaledInt type as the sum output (fx32.32). Then no convert will be required.

    image