ReneBecker_Lumicks
New member
Hi there, first of all thanks for the amazing work on Teensy: it is a great platform 
I am communicating with a peripheral device running at an SPI clock speed of around 25 MHz. I am clocking out 192 bits each 10 microseconds, and if I didn't use asynchronous SPI the microprocessor would be busy with SPI communication for around 80% of the time, which makes it impossible for the rest of the application to run. So, I use asynchronous SPI, which works great.
However, between the end of the SPI transfer and the beginning of the EventResponder callback, there is about a 1.5 us "dead time". Where does this come from? Can I reduce it in some way? Even when using double buffers, the SPI transfer function seems to return false around half of the time (probably on `_dma_state == DMAState::active`), which makes it unable to "overlap" SPI transfers.
I assume the DMA controller used in aynchronous SPI can only handle a single transfer at a time. Is there a way around this?
Relevant parts of the code, which is very much pseudo code:
From start to end timing, this takes 10.4 microsecond, hence the "overlap" when calling the function at 100 kHz
I am communicating with a peripheral device running at an SPI clock speed of around 25 MHz. I am clocking out 192 bits each 10 microseconds, and if I didn't use asynchronous SPI the microprocessor would be busy with SPI communication for around 80% of the time, which makes it impossible for the rest of the application to run. So, I use asynchronous SPI, which works great.
However, between the end of the SPI transfer and the beginning of the EventResponder callback, there is about a 1.5 us "dead time". Where does this come from? Can I reduce it in some way? Even when using double buffers, the SPI transfer function seems to return false around half of the time (probably on `_dma_state == DMAState::active`), which makes it unable to "overlap" SPI transfers.
I assume the DMA controller used in aynchronous SPI can only handle a single transfer at a time. Is there a way around this?
Relevant parts of the code, which is very much pseudo code:
C++:
EventResponder m_responder;
DMAMEM std::array<std::array<std::byte, ...>, 2> dma_double_buffer;
auto* m_empty_buffer = dma_double_buffer[0];
auto* m_filled_buffer = dma_double_buffer[1];
Buffer* buffer; // in external RAM
void startup_code() {
m_responder.attachImmediate([](EventResponder& er) {
buffer->push(m_filled_buffer->data());
// end timing
});
}
void function_running_at_100khz() {
// start timing
if (!SPI.transfer(nullptr, m_empty_buffer->data(), m_frame_size_bytes, m_responder)) {
// transfer failed
}
std::swap(m_empty_buffer, m_filled_buffer);
}
From start to end timing, this takes 10.4 microsecond, hence the "overlap" when calling the function at 100 kHz