cancel
Showing results for 
Search instead for 
Did you mean: 

STM32F7 USART DMA FIFO example?

Grozea.Ion
Associate II
Posted on June 20, 2017 at 15:29

Hello all,

Does anyone has a USART Rx working with DMA + FIFO in circular mode?

#dma #stm32f7 #fifo #circular-mode
6 REPLIES 6
Posted on June 20, 2017 at 17:38

I don't see bandwidth being an issue needing to use FIFO mode DMA, it's not an SDIO or DCMI interface delivering >10MBps

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on June 20, 2017 at 19:31

Hello Clive,

It is not, but as i am learning the F7 i would like to try it.

On the DMA topic...if i remember correctly (i hope my memory is good ) , on the old forum, you had a post for F4 stating that you can trigger a transfer when a

match char

 is detected? I intend to use the DMA for an Xbee communication.

if true, do you still have the link? i tied to find it but i cant or...i'm dreaming

Posted on June 20, 2017 at 23:45

The FIFO options represent a handful of additional settings, if you can set up the Circular DMA you'd be 95% the way there.

I don't recall a pattern match method for the USART, you could trigger via a TIM on a periodic basis.

The were some TIM+DMA+GPIO examples outputting pattern-buffers

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
Posted on July 03, 2017 at 17:01

Hi,

In RM0385 i have found that a character match can be used by using CMF/CMIE + ADD[0:7] from USART_ISR/USART_CR1 + USART CR2. I will try to see if i can make it work

AVI-crak
Senior
Posted on July 03, 2017 at 19:11

DMA + FIFO stores / reads the main memory in blocks of 4 bytes or 8 bytes. But the USART can stop reading in one byte. In this case, the data will be lost.

Additionally, in ring mode (DMA_SxNDTR) = 0xFFFF, constantly !!!
Posted on July 04, 2017 at 00:08

Hello Clive,

I made a try for char match '$' and is working with the following setup

volatile uint32_t myUART_ISR_Val;

void MX_UART7_Init(void)

{

huart7.Instance = UART7;

huart7.Init.BaudRate = 115200;

huart7.Init.WordLength = UART_WORDLENGTH_8B;

huart7.Init.StopBits = UART_STOPBITS_1;

huart7.Init.Parity = UART_PARITY_NONE;

huart7.Init.Mode = UART_MODE_TX_RX;

huart7.Init.HwFlowCtl = UART_HWCONTROL_NONE;

huart7.Init.OverSampling = UART_OVERSAMPLING_16;

huart7.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

huart7.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

if (HAL_UART_Init(&huart7) != HAL_OK)

{

_Error_Handler(__FILE__, __LINE__);

}

//Character match interrupt enable

//A USART interrupt is generated when the CMF bit is set in the USART_ISR register

SET_BIT(huart7.Instance->CR1, USART_CR1_CMIE);

/* Disable the Peripheral */

__HAL_UART_DISABLE(&huart7);

//$ is 36 in DEC

MODIFY_REG(huart7.Instance->CR2, USART_CR2_ADD, ((uint32_t)36 << UART_CR2_ADDRESS_LSB_POS));

/* Enable the Peripheral */

__HAL_UART_ENABLE(&huart7);

}

void UART7_IRQHandler(void)

 

{

 

myUART_ISR_Val = READ_REG(huart7.Instance->ISR);

 

//clear USART_ICR_CMCF

 

huart7.Instance->ICR |= 1 << 17;

 

HAL_UART_IRQHandler(&huart7);

 

}

and in main i do the check

MX_GPIO_Init();

MX_DMA_Init();

MX_UART7_Init();

MX_ADC1_Init();

Xbee_Init();//RX DMA circular - TX DMA normal

_isrflags = READ_REG(huart7.Instance->ISR);

_icrflags = READ_REG(huart7.Instance->ICR);

_cr1its = READ_REG(huart7.Instance->CR1);

_cr2its = READ_REG(huart7.Instance->CR2);

_cr3its = READ_REG(huart7.Instance->CR3);

printf('_isrflags = %d\r\n', _isrflags);

printf('_icrflags = %d\r\n', _icrflags);

printf('_cr1its = %d\r\n', _cr1its);

printf('_cr2its = %d\r\n', _cr2its);

printf('_cr3its = %d\r\n', _cr3its);

printf('Init is done\r\n');

while (1)

{

if(myUART_ISR_Val){

printf('myUART_ISR_Val = %d\r\n', myUART_ISR_Val);

myUART_ISR_Val = 0;

}

}