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.
8 years, 1 month ago.
High speed SPI data transfer - strange delay
Hello all,
I have two mbed boards (Nucleo and Renesas) talking to each other over SPI at 8 MHz just fine. However when I increase the frequency to 32 MHz, a SPI delay appears (or grows) which completely renders the data transfer useless.
Nucleo (master) operates with 216 MHz clock and Renesas Peach board is clocked at 400 MHz, so I wonder what causes this delay and what is the way how to work around it, please?
Picture below shows: A1 - 16 bit clock, A2 - data in 0x01
Any pointers towards solution would be great!
1 Answer
8 years, 1 month ago.
In GR-PEACH, internal clock that is used for the SPI is 66.666MHz. In the case of the slave, you can't communicate fast so much.
If the mode to 1, you can use the burst transfer. You can communicate continuously, so communication speed of the total should become speedy.
Master
#include "mbed.h" SPI spi(P4_6, P4_7, P4_4); // mosi, miso, sclk DigitalOut cs(P4_5); int main() { uint16_t read_buf[30]; spi.frequency(5000000); // 5MHz spi.format(16, 1); // 16 bits, mode 1 // Burst Transfer cs = 0; for (int i = 0; i < 30; i++) { read_buf[i] = spi.write(i); } cs = 1; // for debug for (int i = 0; i < 30; i++) { printf("%d ", read_buf[i]); } printf("\n"); }
Slave
#include "mbed.h" SPISlave device(P4_6, P4_7, P4_4, P4_5); // mosi, miso, sclk, ssel int main() { uint16_t resp = 0; int i = 0; device.frequency(5000000); // 5MHz device.format(16, 1); // 16 bits, mode 1 device.reply(i++); // Prime SPI with first reply while (1) { if (device.receive()) { device.reply(i++); // Make this the next reply resp = device.read(); // Read byte from master } } }
mbed SPI slave driver has no callback of interrupt processing. When the communication speed is too fast, the data set is not in time.