2016-12-28 07:33 PM
I have an '091
I enabled the Usart1 TX DMA as circular, but how can I set the Source address and size ?
<<code>>
hdma_usart1_tx.Instance = DMA1_Channel4;
hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH; hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE; hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE; hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE; hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE; hdma_usart1_tx.Init.Mode = DMA_CIRCULAR; hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW; if (HAL_DMA_Init(&hdma_usart1_tx) != HAL_OK) { Error_Handler(); }__HAL_DMA1_REMAP(HAL_DMA1_CH4_USART1_TX);
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx);
/* Peripheral interrupt init */
HAL_NVIC_SetPriority(USART1_IRQn, 0, 0); HAL_NVIC_EnableIRQ(USART1_IRQn);<</code>>
#dma-source-memory-settingsSolved! Go to Solution.
2017-01-02 02:51 AM
HI,
I have solved all the issues now thanks, it works out the circular buffer seems only relevant to the RX side.
I initialized the Rx DMA system to a circular buffer of 2 bytes. in the 2 call backs, I move the byte into the Rx-buffer.
there is no need to update the UartRxDMA pointers, since it is circular of 2 bytes. This way, I get an interrupt on each byte received.
Works very well.at 460800. I didn't test any other speed.
2016-12-29 01:02 AM
Hi
Marsh.Nick
,In the main loop, you should call thisfunction: 'HAL_USART_Transmit_DMA() '; As parameters, this function needs:
You may use those functions if you need also to
receive
datas :I advise you to refer to the examples providedby ST.
If this solves your issue, please click on correct
:)
.Khouloud.
2016-12-29 04:43 PM
Hi, thanks for the look in;
however, I checked these two examples;
In both examples;
Uart two boards_COMDMA
EvalUartHyperterminalDMA
In;
stm32f0xx_hal_msp.C
Under Line 70:
void HAL_UART_MspInit(UART_HandleTypeDef *huart)
Line 113
hdma_tx.Init.Mode = DMA_NORMAL;
I modified the Hyper terminal example it works.
I made a new CubeMX file, but there are no parameters for using a circular buffer.
I imagine there is a base address, a buffer length and a pointer_in and a pointer_out.
but I cannot find any implementation or detailed description of it.
2017-01-02 01:31 AM
Hi
Marsh.Nick
,After configuring the DMA to work on a circular mode, have you called the '
HAL_USART_Transmit_DMA()' in the main?
Since you're using the USART to transfer data, then you have a buffer where the data you want to transfer are loaded;
Those data will be transmitted to the USARTx_TDR register whenever the TXE bit is set.
Have a look at section 'Continuous communication using DMA' in the reference manual.This will give you more clarification.
Khouloud.
2017-01-02 02:14 AM
Hi
Marsh.Nick
,Glad to hear that your problem is solved.
Happy new year
Khouloud.
2017-01-02 02:51 AM
HI,
I have solved all the issues now thanks, it works out the circular buffer seems only relevant to the RX side.
I initialized the Rx DMA system to a circular buffer of 2 bytes. in the 2 call backs, I move the byte into the Rx-buffer.
there is no need to update the UartRxDMA pointers, since it is circular of 2 bytes. This way, I get an interrupt on each byte received.
Works very well.at 460800. I didn't test any other speed.