Ignore:
Timestamp:
Aug 29, 2025, 7:18:36 PM (15 hours ago)
Author:
f.jahn
Message:

modbus via DMA still BETA, aber bautratenumschaltung implementiert

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/fw_g473rct/Core/Src/usart.c

    r22 r23  
    2828UART_HandleTypeDef huart2;
    2929DMA_HandleTypeDef hdma_usart2_rx;
     30DMA_HandleTypeDef hdma_usart2_tx;
    3031
    3132/* USART1 init function */
     
    8687  /* USER CODE END USART2_Init 1 */
    8788  huart2.Instance = USART2;
    88   huart2.Init.BaudRate = 115200;
     89  huart2.Init.BaudRate = 19200;
    8990  huart2.Init.WordLength = UART_WORDLENGTH_9B;
    9091  huart2.Init.StopBits = UART_STOPBITS_1;
     
    209210    __HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx);
    210211
     212    /* USART2_TX Init */
     213    hdma_usart2_tx.Instance = DMA1_Channel7;
     214    hdma_usart2_tx.Init.Request = DMA_REQUEST_USART2_TX;
     215    hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
     216    hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
     217    hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE;
     218    hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
     219    hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
     220    hdma_usart2_tx.Init.Mode = DMA_NORMAL;
     221    hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW;
     222    if (HAL_DMA_Init(&hdma_usart2_tx) != HAL_OK)
     223    {
     224      Error_Handler();
     225    }
     226
     227    __HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx);
     228
    211229    /* USART2 interrupt Init */
    212230    HAL_NVIC_SetPriority(USART2_IRQn, 0, 0);
     
    257275    /* USART2 DMA DeInit */
    258276    HAL_DMA_DeInit(uartHandle->hdmarx);
     277    HAL_DMA_DeInit(uartHandle->hdmatx);
    259278
    260279    /* USART2 interrupt Deinit */
Note: See TracChangeset for help on using the changeset viewer.