MxCube STM32 UART DMA transmit
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-12-27 3:05 PM
Posted on December 28, 2015 at 00:05
I have this older example, it has a Buffer[] and it is supposed to transfer to DMA:
/**************************************************************************************/
char Buffer[] = ''The quick brown fox jumps over the lazy dog\r\n''; void DMA_Configuration(void) { DMA_InitTypeDef DMA_InitStructure; DMA_DeInit(DMA1_Stream4); DMA_InitStructure.DMA_Channel = DMA_Channel_4; DMA_InitStructure.DMA_DIR = DMA_DIR_MemoryToPeripheral; // Transmit DMA_InitStructure.DMA_Memory0BaseAddr = (uint32_t)Buffer; DMA_InitStructure.DMA_BufferSize = (uint16_t)sizeof(Buffer) - 1; DMA_InitStructure.DMA_PeripheralBaseAddr = (uint32_t)&UART4->DR; DMA_InitStructure.DMA_PeripheralInc = DMA_PeripheralInc_Disable; DMA_InitStructure.DMA_MemoryInc = DMA_MemoryInc_Enable; DMA_InitStructure.DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte; DMA_InitStructure.DMA_MemoryDataSize = DMA_MemoryDataSize_Byte; DMA_InitStructure.DMA_Mode = DMA_Mode_Circular; DMA_InitStructure.DMA_Priority = DMA_Priority_High; DMA_InitStructure.DMA_FIFOMode = DMA_FIFOMode_Enable; DMA_InitStructure.DMA_FIFOThreshold = DMA_FIFOThreshold_Full; DMA_InitStructure.DMA_MemoryBurst = DMA_MemoryBurst_Single; DMA_InitStructure.DMA_PeripheralBurst = DMA_PeripheralBurst_Single; DMA_Init(DMA1_Stream4, &DMA_InitStructure); /* Enable the USART Tx DMA request */ USART_DMACmd(UART4, USART_DMAReq_Tx, ENABLE); /* Enable DMA Stream Transfer Complete interrupt */ DMA_ITConfig(DMA1_Stream4, DMA_IT_TC, ENABLE); /* Enable the DMA Tx Stream */ DMA_Cmd(DMA1_Stream4, ENABLE); } /************************************************************************ Now MxCube created this: /* Peripheral DMA init*/ 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; HAL_DMA_Init(&hdma_usart1_tx); __HAL_LINKDMA(huart,hdmatx,hdma_usart1_tx); Clearly there is no Buffer[], how can I add it in MxCube as it processes all automaticly, and what is _HAL_LINKDMA?
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-12-27 7:37 PM
Posted on December 28, 2015 at 04:37
Look for HAL_UART_Transmit_DMA() and call it with buffer and the other parameters it wants.
Here is a link to a really good document on how to use STM32Cube:Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2015-12-30 4:20 AM
Posted on December 30, 2015 at 13:20
Hi bursic.marko,
As mentioned by HarjitS, you have to add into user code section the appropriate functions for transmission (obviously with declaring appropriate parameters like buffer). You can refer to some examples as this one \STM32Cube_FW_F4_V1.10.0\Projects\STM32F429I-Discovery\Examples\UART\UART_TwoBoards_ComDMA\MDK-ARM.Besides __HAL_LINKDMA() is a macro that ''Associate the initialized DMA handle to the ADC DMA handle'' or ''Associate the initialized DMA handle to the CRYP DMA handle''. More details are available in .Hope this help you-Shahrzad-