fanksting wrote on Tuesday, May 17, 2016:
hello,
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;
}
ISR routine:
void adc_isr(void *CallbackRef)
{
XScuGic_Disable(pScuGicInst, INTC_ADC_INT_ID);
… … …
xQueueSendFromISR(PSMeasEventQueue, &event, &xTaskWoken);
XScuGic_Enable(pScuGicInst, INTC_ADC_INT_ID);
portYIELD_FROM_ISR(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!