Skip to main content
Rabra.1
Associate II
October 8, 2021
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 .

  • October 8, 2021
  • 4 replies
  • 1827 views

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.

4 replies

Javier1
Principal
October 8, 2021

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
October 8, 2021

 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
October 8, 2021

are you using CUBEMX?

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

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

Javier1
Principal
October 8, 2021

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
October 8, 2021

thx , i will try this evening