DSPI Communication timeout issue

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

DSPI Communication timeout issue

34 Views
bharathn3402
Contributor III

I am using the MPC5775B microcontroller with an SPI EEPROM. In my application, CAN messages are received continuously using interrupts, and SPI communication with the EEPROM is also interrupt-driven.

Under heavy CAN bus traffic (e.g., five CAN IDs are received every 1 ms), any EEPROM read operation starts timing out. I am using the DSPI_MasterTransferBlocking() API with a timeout of 10 ms. I also tried increasing the timeout value significantly, but the read operation still fails.

Interestingly, the behavior depends on the amount of data being read. When I attempt to read only a few bytes from the EEPROM, the SPI transfer times out. However, when I read an entire EEPROM page (256 bytes), the read operation completes successfully.

I also observed that if CAN traffic is stopped, the EEPROM read operation succeeds without any issues. I verified the interrupt priorities, and both the CAN and SPI interrupts are configured with the same priority level (priority 0).

I would like to understand:

  • Why do small SPI EEPROM read operations time out under heavy CAN interrupt load, while larger (256-byte) page reads complete successfully?

  • Could this be related to interrupt starvation, the implementation of DSPI_MasterTransferBlocking(), or the interaction between the CAN and DSPI interrupt handlers?

  • Is there any known limitation or recommended configuration for using interrupt-driven DSPI transfers concurrently with high-frequency CAN interrupts on the MPC5775B?

Additionally i debugged the issue by placing break points inside the DSPI_MasterTransferBlocking(),during the debug 

status_t DSPI_MasterTransferBlocking(dspi_instance_t instance,
const void * sendBuffer,
void * receiveBuffer,
uint16_t frames,
uint32_t timeout)
{
DEV_ASSERT((uint32_t)instance < (SPI_INSTANCE_COUNT + DSPI_INSTANCE_COUNT));

status_t status;
dspi_state_t * state = DSPI_state[instance];

if (state->status == DSPI_IN_PROGRESS)
{
return STATUS_BUSY;
}

state->isBlocking = true;
(void)OSIF_SemaWait(&(state->dspiSemaphore), 0);
status = DSPI_MasterTransfer(instance, sendBuffer, receiveBuffer, frames);
if (status == STATUS_SUCCESS)
{
status = OSIF_SemaWait(&(state->dspiSemaphore), timeout);
if (status != STATUS_SUCCESS)
{
(void)DSPI_AbortTransfer(instance);
state->status = DSPI_TRANSFER_FAIL;

return status;
}
}

return STATUS_SUCCESS;
}

dspi transfer status getting success, but "OSIF_SemaWait" after dspi transfer getting timeout.

Tags (3)
0 Kudos
Reply
0 Replies
%3CLINGO-SUB%20id%3D%22lingo-sub-2399953%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3EDSPI%20Communication%20timeout%20issue%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2399953%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3EI%20am%20using%20the%20%3CSTRONG%3EMPC5775B%3C%2FSTRONG%3E%20microcontroller%20with%20an%20%3CSTRONG%3ESPI%20EEPROM%3C%2FSTRONG%3E.%20In%20my%20application%2C%20CAN%20messages%20are%20received%20continuously%20using%20%3CSTRONG%3Einterrupts%3C%2FSTRONG%3E%2C%20and%20SPI%20communication%20with%20the%20EEPROM%20is%20also%20%3CSTRONG%3Einterrupt-driven%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3EUnder%20heavy%20CAN%20bus%20traffic%20(e.g.%2C%20five%20CAN%20IDs%20are%20received%20every%201%20ms)%2C%20any%20EEPROM%20read%20operation%20starts%20timing%20out.%20I%20am%20using%20the%20%3CSTRONG%3EDSPI_MasterTransferBlocking()%3C%2FSTRONG%3E%20API%20with%20a%20timeout%20of%20%3CSTRONG%3E10%20ms%3C%2FSTRONG%3E.%20I%20also%20tried%20increasing%20the%20timeout%20value%20significantly%2C%20but%20the%20read%20operation%20still%20fails.%3C%2FP%3E%3CP%3EInterestingly%2C%20the%20behavior%20depends%20on%20the%20amount%20of%20data%20being%20read.%20When%20I%20attempt%20to%20read%20only%20a%20few%20bytes%20from%20the%20EEPROM%2C%20the%20SPI%20transfer%20times%20out.%20However%2C%20when%20I%20read%20an%20entire%20EEPROM%20page%20(256%20bytes)%2C%20the%20read%20operation%20completes%20successfully.%3C%2FP%3E%3CP%3EI%20also%20observed%20that%20if%20CAN%20traffic%20is%20stopped%2C%20the%20EEPROM%20read%20operation%20succeeds%20without%20any%20issues.%20I%20verified%20the%20interrupt%20priorities%2C%20and%20both%20the%20CAN%20and%20SPI%20interrupts%20are%20configured%20with%20the%20same%20priority%20level%20(priority%200).%3C%2FP%3E%3CP%3EI%20would%20like%20to%20understand%3A%3C%2FP%3E%3CUL%3E%3CLI%3E%3CP%3EWhy%20do%20small%20SPI%20EEPROM%20read%20operations%20time%20out%20under%20heavy%20CAN%20interrupt%20load%2C%20while%20larger%20(256-byte)%20page%20reads%20complete%20successfully%3F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3ECould%20this%20be%20related%20to%20interrupt%20starvation%2C%20the%20implementation%20of%20DSPI_MasterTransferBlocking()%2C%20or%20the%20interaction%20between%20the%20CAN%20and%20DSPI%20interrupt%20handlers%3F%3C%2FP%3E%3C%2FLI%3E%3CLI%3E%3CP%3EIs%20there%20any%20known%20limitation%20or%20recommended%20configuration%20for%20using%20interrupt-driven%20DSPI%20transfers%20concurrently%20with%20high-frequency%20CAN%20interrupts%20on%20the%20MPC5775B%3F%3C%2FP%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EAdditionally%20i%20debugged%20the%20issue%20by%20placing%20break%20points%20inside%20the%26nbsp%3BDSPI_MasterTransferBlocking()%2Cduring%20the%20debug%26nbsp%3B%3C%2FP%3E%3CP%3Estatus_t%20DSPI_MasterTransferBlocking(dspi_instance_t%20instance%2C%3CBR%20%2F%3Econst%20void%20*%20sendBuffer%2C%3CBR%20%2F%3Evoid%20*%20receiveBuffer%2C%3CBR%20%2F%3Euint16_t%20frames%2C%3CBR%20%2F%3Euint32_t%20timeout)%3CBR%20%2F%3E%7B%3CBR%20%2F%3EDEV_ASSERT((uint32_t)instance%20%26lt%3B%20(SPI_INSTANCE_COUNT%20%2B%20DSPI_INSTANCE_COUNT))%3B%3C%2FP%3E%3CP%3Estatus_t%20status%3B%3CBR%20%2F%3Edspi_state_t%20*%20state%20%3D%20DSPI_state%5Binstance%5D%3B%3C%2FP%3E%3CP%3Eif%20(state-%26gt%3Bstatus%20%3D%3D%20DSPI_IN_PROGRESS)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Ereturn%20STATUS_BUSY%3B%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Estate-%26gt%3BisBlocking%20%3D%20true%3B%3CBR%20%2F%3E(void)OSIF_SemaWait(%26amp%3B(state-%26gt%3BdspiSemaphore)%2C%200)%3B%3CBR%20%2F%3Estatus%20%3D%20DSPI_MasterTransfer(instance%2C%20sendBuffer%2C%20receiveBuffer%2C%20frames)%3B%3CBR%20%2F%3Eif%20(status%20%3D%3D%20STATUS_SUCCESS)%3CBR%20%2F%3E%7B%3CBR%20%2F%3Estatus%20%3D%20OSIF_SemaWait(%26amp%3B(state-%26gt%3BdspiSemaphore)%2C%20timeout)%3B%3CBR%20%2F%3Eif%20(status%20!%3D%20STATUS_SUCCESS)%3CBR%20%2F%3E%7B%3CBR%20%2F%3E(void)DSPI_AbortTransfer(instance)%3B%3CBR%20%2F%3Estate-%26gt%3Bstatus%20%3D%20DSPI_TRANSFER_FAIL%3B%3C%2FP%3E%3CP%3Ereturn%20status%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3Ereturn%20STATUS_SUCCESS%3B%3CBR%20%2F%3E%7D%3CBR%20%2F%3E%3CBR%20%2F%3Edspi%20transfer%20status%20getting%20success%2C%20but%20%22OSIF_SemaWait%22%20after%20dspi%20transfer%20getting%20timeout.%3C%2FP%3E%3C%2FLINGO-BODY%3E