I am working on 150825 version of tcp lab code package, and now found an tricky issue, that is, the float operation got corruption when an fpga interrupt occurs periodically whose period is about 3ms. FreeRTOS is running on Zynq. The code snippets are as below:
float operation running in one task:
real32_t fGain = 0.0015f;
real32_t fValue = 0.0f;
int32_t iValue = 0;
for (idx = 0; idx < uiLen; idx ++)
iValue = puiSampBuf[idx];
fValue = (real32_t) iValue;
pAdcSamp[idx] = fValue * fGain;
void adc_isr(void *CallbackRef)
… … …
xQueueSendFromISR(PSMeasEventQueue, &event, &xTaskWoken);
By some logging, I found some corruption, for example, iValue = 6517, but fValue = 1105510016.000000. The float operation is not triggered by interrupt, where they are running independently to each other.
If I add “volatile” on float variable, I notice the corruption occurring frequency go down, but still occur.
If I add the macro definition of portTASK_USES_FLOATING_POINT() at the beginning of task entry function (not add into all tasks with float operation, but add into the task that capture float corruption), the issue still occur.
Really an tricky issue, I don’t know how to handle it so far. Please give me help. Thank you!