ECSPI1 pio (no dma) blocked waiting TC flag
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello,
our company has a board (based on imx6sx) in producition for several years, let's say a thousand pieces around the world.
I have had two reports of a problem that is practically very difficult to reproduce.
The code runs in m4 processor and it is using the ECSPI1 (no DMA).
I was fortunate enough to narrow the problem down to the following block of code (see bold code):
void ECSPI_MasterTransfer(uint8_t* txBuffer, uint8_t* rxBuffer, uint32_t transferSize) { /* Set the burst length to one byte(8 bits) */ ECSPI_SetBurstLength(BOARD_ECSPI_MASTER_BASEADDR, BURST_LENGTH_IN_BYTES(1)); while (transferSize) { /* Fill the TXFIFO */ ECSPI_SendData(BOARD_ECSPI_MASTER_BASEADDR, *txBuffer++); /* start transmission */ ECSPI_StartBurst(BOARD_ECSPI_MASTER_BASEADDR); /* Wait transmission finish */ >>> while (!ECSPI_GetStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoTc)); ECSPI_ClearStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoTc); /* Fill the RXFIFO */ *rxBuffer = ECSPI_ReceiveData(BOARD_ECSPI_MASTER_BASEADDR); rxBuffer++; transferSize--; } }
It seems that could happen that is some circustance the bit ecspiFlagTxfifoTc is not setted to 1, so the code in blocked in the while cycle.
I have read about the TC bit in the RM.
NOTE: The TC bit does not provide a reliable indication that the transfer is complete. Under some
conditions, the TC interrupt can occur before the transfer is completed. If the TC bit is used as an
interrupt source, the XCH bit should be polled after the TC interrupt occurs to accurately confirm
that the transfer is complete.
I'm not able to reproduce the problem anymore , so I would prefer not to change the firmware to insert a solution that actually doesn't even work.
My question is if you know some very strange case (silicon bug) where this bit does not work correctly.
I ask because I think I've watched (I think) everything. At the same time, I am convinced that there is something I may have missed.
Thanks for your support.
Best regards,
Paolo
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Just now I had the chance to see the problem several times.
I verified that when it happens the
- ecspiFlagRxfifoReady flag is set to 1
- ecspiFlagTxfifoTc flag remains at 0
Is it possible ?
I repeat, the problem occurs and then disappears until it is no longer seen.
Only a very small part of the boards shows the problem.
This is the code that shows/solves the problem:
while (!ECSPI_GetStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagRxfifoReady));
int i; for (i=0; i<=200; i++) asm("nop"); // to give flag Tc time to rise
if (!ECSPI_GetStatusFlag(BOARD_ECSPI_MASTER_BASEADDR, ecspiFlagTxfifoTc))
{
LOG_PUTS("PATCH\n");
}
Can you confirm or discard ?
Best regards,
