Skip to main content
Rabra.1
Associate II
Oct 8, 2021 7:32 AM UTC
Question

I'm working on stm32 U5 on an UART with DMA. It's good if the DMA is in normal mode, but when I want to activate the circular mode on RX dma size, my CPU enters in hard fault .

i see in stm32u5xx_hal_dma.c that only normal mode ofr dma is compliant. How can I manage the ciricular mode ?

This topic has been closed for replies.

6 replies

Javier1
Principal
Oct 8, 2021 7:54 AM UTC

Show us the code, speciall atention to the function initialising the DMA where you pass the RXbuffer

hit me up in https://www.linkedin.com/in/javiermuñoz/
Rabra.1
Rabra.1Author
Associate II
Oct 8, 2021 8:48 AM UTC

 HAL_StatusTypeDef ResultHal = HAL_OK;

 pDMAHandle->Instance    = pDMAChannel;

 pDMAHandle->Init.Request  = DMARequest;

 pDMAHandle->Init.Direction = DMADirection;

 if (pDMAHandle->Init.Direction == DMA_PERIPH_TO_MEMORY)

 {

  pDMAHandle->Init.SrcInc = DMA_SINC_FIXED;

  pDMAHandle->Init.DestInc = DMA_DINC_INCREMENTED;

 }

 else

 {

  pDMAHandle->Init.SrcInc = DMA_SINC_INCREMENTED;

  pDMAHandle->Init.DestInc = DMA_DINC_FIXED;

 }

 pDMAHandle->Init.SrcDataWidth     = DMA_SRC_DATAWIDTH_BYTE;

 pDMAHandle->Init.DestDataWidth     = DMA_DEST_DATAWIDTH_BYTE;

 pDMAHandle->Init.Mode         = DMA_NORMAL;

 pDMAHandle->Init.Priority       = DMA_LOW_PRIORITY_LOW_WEIGHT;

 pDMAHandle->Init.TransferAllocatedPort = DMA_SRC_ALLOCATED_PORT0 | DMA_DEST_ALLOCATED_PORT1;

 pDMAHandle->Init.SrcBurstLength    = 1;

 pDMAHandle->Init.DestBurstLength    = 1;

 pDMAHandle->Init.TransferEventMode   = DMA_TCEM_LAST_LL_ITEM_TRANSFER;

  

 if ( pDMAHandle->Init.Mode      == DMA_NORMAL )

 {

  ResultHal               = (HAL_StatusTypeDef) HAL_DMA_Init( pDMAHandle );

 }

 else

 {

  

 }

works well

but How can I change DMA_NORMAL to use circular DMA in my app

Javier1
Principal
Oct 8, 2021 10:26 AM UTC

are you using CUBEMX?

hit me up in https://www.linkedin.com/in/javiermuñoz/
Rabra.1
Rabra.1Author
Associate II
Oct 8, 2021 11:37 AM UTC

yes , i can use it, just to create and understand the strcuture

Javier1
Principal
Oct 8, 2021 11:54 AM UTC

well, good news, CUBEMX has an option for you :D

0693W00000FBtFJQA1.png 

hit me up in https://www.linkedin.com/in/javiermuñoz/
Rabra.1
Rabra.1Author
Associate II
Oct 8, 2021 1:56 PM UTC

thx , i will try this evening