Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 2 of 2

Thread: Non Blocking SPI transfer on Teensy 4.0

  1. #1
    Senior Member
    Join Date
    Feb 2019

    Non Blocking SPI transfer on Teensy 4.0

    I want to start an SPI transfer (16 Bits) and while data is beeing transferred I want to do some computation. All this should happen within an interrupt-routine. As far as I have experienced the usual transfer16(..) is blocking. How can I initiate a non blocking transfer? How do I test for completion of this transfer? For my application that is not necessary because my computation lasts longer than the time the spi-transfer takes.

    Any suggestions?

  2. #2
    Senior Member+ KurtE's Avatar
    Join Date
    Jan 2014
    Note: There was a recent thread: that talked about non-blocking transfers
    That talked some about doing DMA transfers...

    Note: The SPI library has a non-blocking 8 bit transfer method:
    	bool transfer(const void *txBuffer, void *rxBuffer, size_t count,  EventResponderRef  event_responder);
    More of the details up on the other thread... Like what is an EventResponder. Which in this case the method takes a reference to an EventResonder class.
    The class allows you to get a callback when it completes and/or you can query state...
    You can also control when the callback happens (immediate, on yield, on timer...)

    But again this is 8 bit transfers.... Before this was integrated into SPI library I had versions of this method as well as the blocking version for 16 bit transfers, but we decided to not integrate it as we were already polluting the class with enough non-standard SPI methods.

    If you want to roll your own, there are a few different display drivers that we have that do this, including my ILI9341_t3n, the ST7735_t3 and others. But this requires learning more about DMA
    and the like.

    One option is to go ahead and use the 8 bit async transfer, knowing you may need to reverse the bytes in your buffer you are trying to send out.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts