Results vary between different versions of compilation and execution.
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)
Best 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.
0
Answers
-
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.
0