2023-06-05 11:22 PM - edited 2023-11-20 03:52 AM
I already try for send five byte data in UART DMA. I am using the controller in STM32G030K6T6. Data transmition is working properly but output is did not taken properly. The problem was am transmit data five bytes for UART_DMA but DMA transmit only two bytes data. HAL_UART_Transmit_DMA call in timer interrupt handler to check the output for just now. The output is came but this is not proper output. this method for just call in to the interrupt handler output is continuously came for five bytes data. I need a output for 500 millisec once Five Bytes data transmit. I attach the output for picture and code. please tell what can I do for next step.
#include "main.h"
TIM_HandleTypeDef htim3;
UART_HandleTypeDef huart2;
DMA_HandleTypeDef hdma_usart2_tx;
/* USER CODE BEGIN PV */
uint16_t tim=0;
uint8_t tx_buf[5]= {0x01,0x02,0x03,0x04,0x05};
/* USER CODE END PV */
void SystemClock_Config(void);
static void MX_GPIO_Init(void);
static void MX_DMA_Init(void);
static void MX_USART2_UART_Init(void);
static void MX_TIM3_Init(void);
int main(void)
{
HAL_Init();
SystemClock_Config();
MX_GPIO_Init();
MX_DMA_Init();
MX_USART2_UART_Init();
MX_TIM3_Init();
/* USER CODE BEGIN 2 */
HAL_TIM_Base_Start_IT(&htim3);
HAL_UART_Transmit_DMA(&huart2, tx_buf, sizeof(tx_buf)); // 500 msec once
/* USER CODE END 2 */
while (1)
{
}
}
void TIM3_IRQHandler(void)
{
/* USER CODE BEGIN TIM3_IRQn 0 */
/* USER CODE END TIM3_IRQn 0 */
HAL_TIM_IRQHandler(&htim3);
/* USER CODE BEGIN TIM3_IRQn 1 */
tim++;
if(tim==500)
{
__HAL_DMA_ENABLE(huart2.hdmatx);
tx_buf[0] = 0x01;
tx_buf[1] = 0x02;
tx_buf[2] = 0x03;
tx_buf[3] = 0x04;
tx_buf[4] = 0x05;
tim=0;
__HAL_DMA_DISABLE(huart2.hdmatx);
}
/* USER CODE END TIM3_IRQn 1 */
}
Solved! Go to Solution.
2023-06-06 06:02 AM
A similar question for a same device is active.
https://community.st.com/s/question/0D53W00002HkOODSA3/stm32g030-uartdma
Does it comes from you too?
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-06-06 06:17 AM
2023-06-06 06:32 AM
this question is another member post.
2023-06-06 06:34 AM
STM32G030K6T6 This is our Board.
2023-06-06 07:58 AM
Here back a working solution. I tested it on STM32G030 and I get array buffer bytes every 500ms.
In your initial USART_ChecK, the Systick interrupt never happens. I don't know why?
Let try it and let me know ?
Best regards,
Romain,
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-06-06 08:07 AM - edited 2023-11-20 03:53 AM
I join as an attachment a capture using oscilloscope.
C1: Is the USART2 DMA transfer each 500ms (small vertical yellow line each 500ms) corresponding to HAL_UART_Transmit_DMA()
And
Z1: Is zoom window of one vertical yellow line, it shows the bytes array transmitted.
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-06-06 09:47 PM
ok, which code your using. are you using systick timer code.
2023-06-06 11:15 PM
Hi @mrsmile (Community Member)
I use the code USART_CheK_ST in the archive that I send to you. It uses the Systick Timer and that's the capture I show.
Does it works now for you?
Does it helps?
Thank you for feedback.
romain
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.
2023-06-07 01:00 AM
Thank you so much your response @RomainR. sir, code is working properly sir and Five bytes data send UART_DMA in 500 ms once working good.
2023-06-07 01:04 AM
Very good new.
In this case, thank you to apply the following below:
In order to give better visibility on the answered topics, please click on 'Select as Best' on the reply which solved your issue or answered your question. See also 'Best Answers'
To give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.