cancel
Showing results for 
Search instead for 
Did you mean: 

TOUCHGFX AND UART AND SHOWING DATA ON SCREEN

nsabo.1
Associate II

Hi, I want to receive data by UART.

In MX, I have initialized it:

this is the code:

 huart1.Instance = USART1;

 huart1.Init.BaudRate = 115200;

 huart1.Init.WordLength = UART_WORDLENGTH_8B;

 huart1.Init.StopBits = UART_STOPBITS_1;

 huart1.Init.Parity = UART_PARITY_NONE;

 huart1.Init.Mode = UART_MODE_TX_RX;

 huart1.Init.HwFlowCtl = UART_HWCONTROL_NONE;

 huart1.Init.OverSampling = UART_OVERSAMPLING_16;

 if (HAL_UART_Init(&huart1) != HAL_OK)

 {

  Error_Handler();

 }

and I want to receive and transmit in special screens,

here is the code: I want to send and receive in screen7.

void Screen7View::handleTickEvent()

{

tickcounter++;

uint8_t a[] = "68";

//HAL_UART_Transmit(&huart1,(uint8_t*)a,8,10);// Sending in normal mode

//HAL_Delay(1000);

if(HAL_UART_Transmit_IT(&huart1, (uint8_t *)a, 😎 != HAL_OK) {

      Error_Handler();

   } 

}

for test, first of all, I want to transmit an integer assigned 68; on the other hand when other machine received 68 , it should make a sound.

the problem is UART does not work...

Can you help me what is the problem??

Thanks.

2 REPLIES 2

Doesn't work is a bit vague and non-specific.​

Do you initialize the pins.

Does data come out the pin, check with a scope​?

Do you have an interrupt Handler or callback function?

There aren't 8 characters in the string, and there's no termination like space or carriage return.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..

Hi, I fixed the problem now I can receive data but I have still problem through sending. I use this function sending an integer to main board but it does not work.

  HAL_UART_Transmit(&huart1,(const uint8_t*)c,sizeof(c),500);

HAL_UART_TxCpltCallback(&huart1);