This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

SPI slave peripheral receive interrupt processing

SPI Slave configuration On nRF52

Hi,

I am trying to configure the SPI slave peripheral for interrupt based communicaton with a SPI master In previous work with ARM based chips, the typical sequence I have followed would be :

  1. configure the SPI slave peripheral

  2. configure the SPI data processing task

  3. Enable the SPI receive interrupt (to handle receive data in the ISR)

During regular operation the sequence that would typically be followed is then :

  1. In IRQ, check status bits and clock in the SPI peripheral data

  2. Upon completion of a frame, the following may then be done ( there are various ways, but this is the simplest way )

a) disable the RX IRQ

b) signal the SPI data processing task, which will then process the data and then if necessary transmit a response ( again via the SPI peripheral)

c) re-enable the SPI RX IRQ.

And the process would repeat. The tpyical error handling management is left out for conditions like over-run etc. But, this is typically the basis of what I have done in the past. Most of this has been done at the CMSIS level ( or something close to this). This is the first time I have used the nRF52 SDK

I looked thru the SPI slave example and have a couple of questions based on the exposed API and the functionality in the SPI slave main.c

  1. It is not clear how the SPI slave can be configured to handle receive functionality. Does the registered event handler also get called in the event that the SPI slave peripheral detects incoming data. If so, what is the sequence of events that causes the event handler to be invoked ( is this based upon assertion of the /CS or clocking of incoming data or ...) The documentation that I read on the infocenter ( infocenter.nordicsemi.com/index.jsp is not clear on how the sequence of events transpires on a spi slave receive operation

  2. Is it possible to reconfigure the SPI interrupt based on incoming frames and the state of reception

  • First of all you should use SDK 12 (link to infocenter is for SDK 0.9.2, which is old and not production release version).

    The event handler is called when the transaction is done (CSN goes high after valid transaction) or when the buffers are configured (semaphore is released -> SPIS peripheral is ready for transaction). There is no way to get event when CS goes low. See the Product Specification for the SPIS peripheral.

    I did not quite understand what you aim to do and why you are uncertain if the SPIS driver from the SDK can be used.

Related