Reading SPI accelerometers

What are you developing?
stevestrong
Posts: 502
Joined: Fri Dec 27, 2019 4:53 pm
Answers: 8
Location: Munich, Germany
Contact:

Re: Reading SPI accelerometers

Post by stevestrong »

misterbo wrote: Tue Mar 30, 2021 3:11 pm Thanks! I eliminated the lines for beginTransaction and endTransaction, and I'm getting slightly better results (12.5kHz) but I didn't get your first point; are you suggesting to use something like

Code: Select all

dest=SPI.transfer(zeros, count)
instead of

Code: Select all

  for (uint8_t ii = 0; ii < count; ii++)
  {
    dest[ii] = SPI.transfer(0);
  }
?
Yes, this is why I asked you about the used core.
In Libmaple (aka Roger's) core there is an SPI.transfer function which transfers block-wise the data to and from the slave device, see: https://github.com/rogerclarkmelbourne/ ... SPI.h#L285, which accepts data arrays for read and write data separately,
There is a variant of the transfer function to input one byte and read an array.
You have to check whether such a function is available in STM core as well, because this would really speed up your app.
Post Reply

Return to “Projects”