cancel
Showing results for 
Search instead for 
Did you mean: 

STM32L476RG SPI gap between transmission

Posted on April 27, 2017 at 09:20

Hello all,

I'm trying to setup the STM32L476RG via SPI with an external DAC (SPI clock speed: 40MHz). I used the HAL_SPI_Transmit() function to transmit a 24Bit word.After one transmission there is a gap of 2.5�s befour the new transmission starts. For my application I need a fast transmission. Is there a posibility to purge the gap?

Thank you in advance,

Fabian

#stm32l4 #spi #spi-bus #gap
12 REPLIES 12
AvaTar
Lead
Posted on April 27, 2017 at 13:48

You might need to show relevant part of your code, this is definitely not a hardware/peripheral issue.

Profiling and measuring your application would be even better.

Posted on April 27, 2017 at 17:37

Tell HAL_SPI_Transmit() to send multiple words, better still look at the code behind-the-curtain, the HAL permits/enables a whole circus of stupidity. Avoid.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
DOSS FOF
Associate II
Posted on May 19, 2017 at 17:26

Hello Clive ,

Do you manage to resolve this issue ?

Posted on May 19, 2017 at 20:05

Not my issue, no time invested in it here.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal
Posted on May 21, 2017 at 11:13

When high baud rate is needed, use dma with its interrupts on the rx dma side only. Then the isr will define the pause time between packets transmission.

Posted on May 21, 2017 at 13:16

The original post was too long to process during our migration. Please click on the provided URL to read the original post. https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I6sJ&d=%2Fa%2F0X0000000bx5%2FSoZzDulIWYalRUkJ_kbRaezKGcaixocsT0EVyg1sWCo&asPdf=false
Posted on May 22, 2017 at 01:07

Spi requires 2 dma streams, one for tx and one for rx. It seems only one declared here.

Posted on May 22, 2017 at 01:23

Even though I don't receive any message (transmission only). 

Posted on May 22, 2017 at 12:13

         DMA1_init_struct.Instance->CMAR = Txdata;    // Specify memory address that contains data to transmit.

            DMA1_init_struct.Instance->CPAR  = SPI1->DR;    // Data register of the SPI peripheral to read received data.

            DMA1_init_struct.Instance->CNDTR = 16;            // Number of elements to receive (our buffers consist of 8 byte elements)

            DMA1_init_struct.Instance->CCR   |= DMA_CCR_EN|DMA_CCR_TCIE|DMA_CCR_HTIE  ; // Enable the DMA stream

I don't use Cube but I'd say you are supposed to use some prescribed incantation rather directly manipulate the DMA registers. In other words, I wouldn't mix the two approaches.

            DMA1_init_struct.Instance->CPAR  = SPI1->DR;    // Data register of the SPI peripheral to read received data.

You want to take the address of data register, not its content.

JW