Skip to main content
Manu Abraham
Senior
March 8, 2017
Question

STM32F334 SPI TX DMA

  • March 8, 2017
  • 1 reply
  • 685 views
Posted on March 08, 2017 at 15:04

Hi,

Followed a similar thread with SPI Rx Slave in

https://community.st.com/0D50X00009XkhZKSAZ

 

followed the same, but used Channel 3 instead..

The RM0364, DocID025177 Rev 2, Page &sharp179, Figure 20. STM32F334xx DMA1 request mapping,

states that DMA1 Channel 3 needs remapping to be used with SPI1. It appears to be the same for

any DMA Channel.

Nevertheless it appears that all SPI TX DMA transfers do need a DMA remap, according to the

figure 20. But well, that aside ..

Though I tried remap, there appears to be no change. I have connected a scope to the SCK pin,

there appears to be no activity at all.

Any thoughts, on the following code ?

Thanks.

null
    This topic has been closed for replies.

    1 reply

    Manu Abraham
    Senior
    March 9, 2017
    Posted on March 09, 2017 at 06:51

    Replying to my own post,

    Found a small bug, which caused no activity on the SCK line:

    It should've been Tx instead of Rx:

        /* DMA request enable    */

        SPI_I2S_DMACmd(SPI1, SPI_I2S_DMAReq_Tx, ENABLE);

    I now see one single SCK pulse and the following debug output:

    ========================

       SPI1 LCD DMA Debug

    ========================

    Frames init

    SPI1 Init

    DMA1 CH3 Init

    NVIC Init

    CH3 IRQ

    TE3

    IRQ enabled

    Backlight ON

    -------------= SPI1 REG dump =-------------

           SPI_CR1     : 0xc36d

           SPI_CR2     : 0x702

           SPI_SR      : 0x02

           SPI_DR      : 0x00

           SPI_CRCPR   : 0x07

           SPI_RXCRCR  : 0x00

           SPI_TXCRCR  : 0x00

    -------------------------------------------

    Since the original issue past, Wondering now why the TE3 ?

    Any thoughts/suggestions/comments ?

    Thanks.

    S.Ma
    Principal
    March 9, 2017
    Posted on March 09, 2017 at 08:57

    If there is no example in Cube for this and assuming this is SPI master mode, try first in 2 lane mode with TX and RX connected to a DMA stream. The RX stream, if unused, can cycle through a few RAM bytes, and the GPIO does not need to physically exist.

    While in std lib, this code seems quite explicit on how to play with SPI as master and DMA (SPI IP without FIFOs)

    https://community.st.com/community/contribute-your-knowledge/blog/2016/12/31/interrupt-based-state-machine

     
    Manu Abraham
    Senior
    March 9, 2017
    Posted on March 09, 2017 at 17:05

    Thanks. I will take a look. There weren't any examples for the F334 and hence..

    Moving:

    SPI_Cmd(SPI1, ENABLE);

    immediately after SPI_Init()

    fixed the issue. Weird though..

        SPI_Init(SPI1, &spi);

        SPI_Cmd(SPI1, ENABLE);

        putstr(USART1, 'SPI1 Init\r');