cancel
Showing results for 
Search instead for 
Did you mean: 

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 .

Rabra.1
Associate II

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

6 REPLIES 6
Javier1
Principal

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

we dont need to firmware by ourselves, lets talk
Rabra.1
Associate II

 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

are you using CUBEMX?

we dont need to firmware by ourselves, lets talk
Rabra.1
Associate II

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

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

0693W00000FBtFJQA1.png 

we dont need to firmware by ourselves, lets talk
Rabra.1
Associate II

thx , i will try this evening