cancel
Showing results for 
Search instead for 
Did you mean: 

Is DMA Circular mode working in STM32F746G-Disco?

sv1eia
Associate II
Posted on September 13, 2015 at 21:29

Hi,

I have a project in STM32F746G-Disco with its SPDIFRX interface. I was able to use STM32CubeMX to generate the intializations and the sceleton project. As it is right now, I can receive the half and complete interrupts but only once each. The HAL_SPDIFRX_RxHalfCpltCallback and the HAL_SPDIFRX_RxCpltCallback, are called only once each and then no more calls to them are send. That means the DMA is working and retrieves samples from the SPDIFRX interface but it is not reloading the DMA transfer size or the other DMA parameters, in order to continue from the start again. It runs only once.

/* Peripheral DMA init*/
hdma_spdif_rx_dt.Instance = DMA1_Stream1;
hdma_spdif_rx_dt.Init.Channel = DMA_CHANNEL_0;
hdma_spdif_rx_dt.Init.Direction = DMA_PERIPH_TO_MEMORY;
hdma_spdif_rx_dt.Init.PeriphInc = DMA_PINC_DISABLE;
hdma_spdif_rx_dt.Init.MemInc = DMA_MINC_ENABLE;
hdma_spdif_rx_dt.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
hdma_spdif_rx_dt.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
hdma_spdif_rx_dt.Init.Mode = DMA_CIRCULAR;
hdma_spdif_rx_dt.Init.Priority = DMA_PRIORITY_LOW;
hdma_spdif_rx_dt.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
hdma_spdif_rx_dt.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL;
hdma_spdif_rx_dt.Init.MemBurst = DMA_MBURST_SINGLE;
hdma_spdif_rx_dt.Init.PeriphBurst = DMA_PBURST_SINGLE;
HAL_DMA_Init(&hdma_spdif_rx_dt);
__HAL_LINKDMA(hspdifrx,hdmaDrRx,hdma_spdif_rx_dt);

And that is the portion of code generated from CubeMX, it clearly shows the ''

Mode = DMA_CIRCULAR

'' but for some reason it stops at only one iteration. Anyone has a hint on this? Christos
6 REPLIES 6
Nesrine M_O
Lead II
Posted on September 15, 2015 at 15:37

Hi Christos,

Could you please verify the bit enable of DMA1_Stream1 (bit 0: EN: Stream enable on the DMA_SxCR register) and PFCTRL bit.

Because When the peripheral is the flow controller (bit PFCTRL=1) and the stream is enabled (bit EN=1), then the CIRC: Circular mode bit is automatically forced by hardware to 0.

-Syrine 

sv1eia
Associate II
Posted on September 15, 2015 at 17:56

Hi Syrine,

Thanks for answering.

Yet, I think I've found the cause of the problem.

It seems that lies in the STM32Cube_FW_F7_V1.1.0 library itself, in the HAL file stm32f7xx_hal_spdifrx.c lines 1000 to 1003.

There, upon DMA completion, the library function SPDIFRX_DMARxCplt(DMA_HandleTypeDef *hdma), is disabling DMA without checking if it is in Circular mode.

In other HAL files, there, exist a Circular mode flag checking and the DMA is not cleared if it is found to be in Circular mode.

Unfortunately that error happens only in the rarely used SPDIFRX HAL files.

So, it seems to me that in the next version of the CubeF7 library you should indicate that to your team and rectify it.

Regards,

Christos

Nesrine M_O
Lead II
Posted on September 15, 2015 at 18:19

Hi Christos,

I will check this problem with our development team & come back to you.Sorry for the inconvenience may bring.

-Syrine –

sv1eia
Associate II
Posted on September 15, 2015 at 19:27

Ok Syrine,

For the time being, I've coded the function as this and it looks its working ok, until you release the next CubeF7 lib.

static void SPDIFRX_DMARxCplt(DMA_HandleTypeDef *hdma)
{
SPDIFRX_HandleTypeDef* hspdif = ( SPDIFRX_HandleTypeDef* )((DMA_HandleTypeDef* )hdma)->Parent;
if((hdma->Instance->CR & DMA_SxCR_CIRC) == 0)
{
/* Disable Rx DMA Request */
hspdif->Instance->CR &= (uint16_t)(~SPDIFRX_CR_RXDMAEN);
hspdif->RxXferCount = 0;
hspdif->State = HAL_SPDIFRX_STATE_READY;
}
HAL_SPDIFRX_RxCpltCallback(hspdif); 
}

Christos
megahercas6
Senior
Posted on September 16, 2015 at 21:19

I had very long ( and still have) problem with SPI and DMA in circular mode.

If you could make complete example how to do that in STM32F7, i would be very happy, since no one was able to help me, or point in right direction, apart read manual...

https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/Flat.aspx?RootFolder=https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/STM32F7%20code%20samples%20for%20SPI%20and%20DCMI%20in%20DMA%20Circular%20mode%20with%20small%20reward&FolderCTID=0x01200200770978C69A1141439FE...

Nesrine M_O
Lead II
Posted on October 26, 2015 at 08:30

Hi christos,

Sorry for the late response.

Your reported issue is confirmed by our team and will be fixed in coming release of the STM32cubeF7 package..

Thank you very much for your contribution to the enhancement of our STM32 related solutions.

-Syrine –