Race condition in the LPC5410X SPI master driver

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

Race condition in the LPC5410X SPI master driver

670 Views
timcarney
Contributor II

While developing using the LPC5410X SPI master driver, I have discovered a race condition.

The initial SPI transfer is initiated by calling the interrupt handler (Chip_SPIM_XferHandler) from the application. When sending data, the TXDAT register is set with the current byte to be sent and then the index into the transmit buffer is incremented.

It is possible that the SPI_INTENSET_SSAEN interrupt can occur between setting the TXDAT register and incrementing the index into the transmit buffer. When this occurs, the SPI driver will send the same byte twice (once called from the application and the second called in the ISR).

For our application, I have modified the SPI driver to increment the pointer into the transmit buffer prior to setting the TXDAT register. While this seems to get the driver to behave as our application needs it to, I'm not comfortable that this is the correct solution, especially for applications that may be using the SPIM_XFER_OPTION_EOT option.

Labels (1)
0 Kudos
2 Replies

533 Views
soledad
NXP Employee
NXP Employee

Hi,

Please check the below link and let me know if this helps,

LPCOpen master SPI on 5410x 


Have a great day,
Sol

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos

533 Views
timcarney
Contributor II

Sol,

I have found a fix that works for me, but I would like to report my findings so that a change can be made to the LPCOpen files. How should I proceed?

Thanks,

Tim Carney

Senior Software Engineer

Pivot-Avatar

www.avatar-eng.com<http://www.avatar-eng.com/>;

14360 W. 96 Terrace

Lenexa, KS 66215

913.897.6757 Main

timc@avatar-eng.com

Statement of Confidentiality

This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the sender. This message contains confidential information and is intended only for the individual named. If you are not the named addressee you should not disseminate, distribute or copy this e-mail. Please notify the sender immediately by e-mail if you have received this e-mail by mistake and delete this e-mail along with any attachments from your system. If you are not the intended recipient you are notified that disclosing, copying, distributing or taking any action in reliance on the contents of this information is strictly prohibited.

0 Kudos