AnsweredAssumed Answered

SPI Interbyte delay

Question asked by stokic.srdjan on Feb 27, 2015
Latest reply on Feb 28, 2015 by childress.steve
Hi all,

I'm doing some testing with STM32L151, and I'm trying to send a bulk of data over SPI.

I'm using SPI in interrupt mode, my CPU is set to 32MHz, SPI is set to 16MHz.

When I send a byte, I'm waiting for a SPI_I2S_IT_TXE interrupt so that I can move another byte into the DR register, but when I look at my scope following occurs:

I can see that SPI clocked out 8 bits of data, but the TXE interrupt fires approximately 2 byte intervals later. As far as I know, it should fire as soon as 1 bit is clocked out on the SPI. 1 byte is clocked out in 500nS (which is correct for 16Mhz), but then next byte is delayed approximately 1ms or even more. I have this gap of 2 byte intervals between bytes on the SPI. (See attached image)

To make things even stranger, when I decrease the SPI speed to 8MHz, or 4MHz, this mechanism starts to work more reliably. I can see that the TXE interrupt fires much sooner after the 1st clocked out bit, and bytes are sent immediately one after another.

Almost seems like the CPU is not able to transfer data from the DR to shift register fast enough.

Any ideas what might be wrong?


Attachments

Outcomes