Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years, 9 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 :
sample spi code
#include "mbed.h" Serial pc(UART_TX, UART_RX); SPI spi(p16, p15, p13); // mosi, miso, sclk int main() { pc.baud(115200); spi.format(8,1); spi.frequency(8000000); while (1) { spi.write(0x01); spi.write(0xFF); spi.write(0xAA); wait(5); } }
is this normal behavior ?
Question relating to:
2 Answers
10 years, 9 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).
10 years, 9 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 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 26 Jan 2014I 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 26 Jan 2014