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

modbus via DMA still BETA, aber bautratenumschaltung implementiert

Location:
trunk/fw_g473rct/Core/Src
Files:
3 edited

Legend:

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

    r22 r23  
    6363  HAL_NVIC_SetPriority(DMA1_Channel6_IRQn, 0, 0);
    6464  HAL_NVIC_EnableIRQ(DMA1_Channel6_IRQn);
     65  /* DMA1_Channel7_IRQn interrupt configuration */
     66  HAL_NVIC_SetPriority(DMA1_Channel7_IRQn, 0, 0);
     67  HAL_NVIC_EnableIRQ(DMA1_Channel7_IRQn);
    6568
    6669}
  • trunk/fw_g473rct/Core/Src/stm32g4xx_it.c

    r22 r23  
    6363extern DMA_HandleTypeDef hdma_adc5;
    6464extern DMA_HandleTypeDef hdma_usart2_rx;
     65extern DMA_HandleTypeDef hdma_usart2_tx;
    6566extern UART_HandleTypeDef huart1;
    6667extern UART_HandleTypeDef huart2;
     
    292293
    293294/**
     295  * @brief This function handles DMA1 channel7 global interrupt.
     296  */
     297void DMA1_Channel7_IRQHandler(void)
     298{
     299  /* USER CODE BEGIN DMA1_Channel7_IRQn 0 */
     300
     301  /* USER CODE END DMA1_Channel7_IRQn 0 */
     302  HAL_DMA_IRQHandler(&hdma_usart2_tx);
     303  /* USER CODE BEGIN DMA1_Channel7_IRQn 1 */
     304
     305  /* USER CODE END DMA1_Channel7_IRQn 1 */
     306}
     307
     308/**
    294309  * @brief This function handles USART1 global interrupt / USART1 wake-up interrupt through EXTI line 25.
    295310  */
  • 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.