2

It might be a bit out there, but for a project that I am working on, my word size default is 24bits (3x8-bit), of which the first 8-bits are data and the next 16-bits are data. I would like to transfer it out of the system as fast as possible with minimal calls to the sub-routines. For this I am trying to reduce the number of calls, I have managed to reduce it from 3 to 2, Can I possibly make it 1 call.

  1. My first attempt was to use 3x SPI.transfer() Second was to use 1x

  2. SPI.transfer() and 1x SPI.transfer16()

I would like to know what would be the ideal way to write a SPI.transfer24 function.

asked Dec 23, 2020 at 19:08
4
  • What teensy are you using? Commented Dec 23, 2020 at 19:40
  • teensy 4.0 is the one i am using Commented Dec 23, 2020 at 20:03
  • And how much difference do you think making 1 function call as opposed to 2 will make at 600MHz? Will you even be able to tell? Commented Dec 23, 2020 at 20:04
  • 1
    @Majenko that is a fair point, but if you try to look at a digital logic level analyzer each word seems to to have a small impact, but when you write ~4M words a second it adds up unfortunately. Commented Dec 23, 2020 at 20:19

1 Answer 1

2

You can't. The teensy 4.0 has hardware support for 8-bit, 16-bit and 32-bit transfers. Not 24-bit transfers.

But at 600MHz the overhead of making a function call is negligible anyway - certainly compared to the speed of SPI which is at best about 30x slower than the CPU operates at.

If you want high throughput you won't be wanting to use the SPI library anyway, instead you'd be using DMA to transfer your data with minimal CPU intervention.

answered Dec 23, 2020 at 20:19

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.