The following code results in incorrect values calculated for the variable: dataConfigWord
...
for(outerIndex = 0; outerIndex < 4; ++outerIndex) { uint32 outerIndexToOffsetAddr[] = {0x1880, 0x1C80, 0x2080, 0x2480}; uint32 offsetAddr = outerIndexToOffsetAddr[outerIndex]; for(innerIndex = 0; innerIndex < 4; ++innerIndex) { uint64 dataConfigWord = offsetAddr + innerIndex; /* Value of dataConfigWord gets calculated INCORRECTLY! */ ScratchBuffer1[ScratchBufferIndex++] = dataConfigWord; } }
...
If I move the const array outerIndexToOffsetAddr outside of the loop, OR if I add an asm "nop" in the loop to break the pipeline, then the value of dataConfigWord is correct. I understand that the former is more efficient, and also that it can be declared static or const. However, the code as it stands should still work without producing incorrect result, correct?
I am using CCS 5.1.x with CGT 7.3.8 and writing code for c6604 / c6602 DSP. Compiler options used include -o3 and -mf3.
I have attached the sandbox code to reproduce the problem with.
Thank you,
BR