9 years, 2 months ago.

1.6 us gap between sending SPI data

Hi When I try to send 3 bytes of SPI Ddata I get 1.6us gap between each byte as shown in picture : /media/uploads/sargonout/20121229_400909.png

sample spi code

#include "mbed.h"
Serial pc(UART_TX, UART_RX);

SPI spi(p16, p15, p13); // mosi, miso, sclk

int main() {
    while (1) {    

is this normal behavior ?

Question relating to:

DipCortex is a easy to use ARM Cortex M3 development board in a standard 40 pin through hole DIP package, targeted at higher performance applications. Utilising the NXP LPC1347 the …

2 Answers

9 years, 2 months ago.

That is expected behavior, the mbed libs always read back the data written by SPI, so the code waits until it is finished, then reads that, writes the next value, then the peripheral has to start sending, etc.

If it is important to really send as fast as possible (for example with SPI TFT displays), there is https://mbed.org/users/Sissors/code/BurstSPI/, although currently it doesn't support the LPC1347. (I will probably soonish expand support to at least some others, but the LPC1347 won't be done by me at least since I don't have it).

Accepted Answer
9 years, 2 months ago.

You can bypass the mbed lib and use the SPI FIFO directly to eliminate the gap. It would make your code less portable. I could contribute to the burst spi library if you like.

I don't know about Tomislav, but I would like it ;).

posted by Erik - 26 Jan 2014

I would like to drive WS2811 with SPI simmilar to this code https://github.com/RickKimball/fabooh/blob/master/include/cortex-m0/core/drivers/ws2811.h Because bitbang of gpio is slow ( fast gpio lib ?? )

posted by Tomislav Arnaudov 26 Jan 2014

I have a blog entry for driving a string of WS2812B very similar to the WS2811. I used SPI to generate the bit-pattern I also packed 4bits into each spi fifo slot using a lookup table. http://www.soldersplash.co.uk/2013/12/christmas-tree-dipcortex-ws2812b code for it is on GitHub

Erik, shall have a look at adding LPC1347 support to your library

posted by Carl - SolderSplash Labs 26 Jan 2014