2015-09-13 12:29 PM
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
2015-09-15 06:37 AM
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.-Syrine2015-09-15 08:56 AM
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,Christos2015-09-15 09:19 AM
Hi Christos,
I will check this problem with our development team & come back to you.Sorry for the inconvenience may bring.-Syrine –2015-09-15 10:27 AM
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
2015-09-16 12:19 PM
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...2015-10-26 12:30 AM
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 –