cancel
Showing results for 
Search instead for 
Did you mean: 

i got touchgfx + uart interrupt problem.

YJMoon
Associate III

Hi.

I am using the uart on the touchgfx project on the stm32f746-disco board, but when I continue the uart interrupts, I get stuck.

There were two cases of stuck state.

1. Screen stops but uart is running

2. Board is completely frozen

The uart interrupt code I created seems to be wrong and I am not sure how to fix it and I need help.

I am currently switching four 480 * 272 screens every 4 seconds using only the resources that the 746disco board has, and I am in the process of testing qspi MemoryMappedMode.

Ethernet does not cause any problems when sending and receiving data in 100ms increments. In case of uart, the board is stopped after a certain period of time even though data is transmitted much slower.

Below is the uart code that I use.

The reason for this is that the interruption of the uart HAL library, which works normally in other projects, is not responding to the projects ported by touchgfx.

This is only a problem with rx interrupts.

In case of tx, I am using polling method instead of interrupt, and there is no problem here.

0690X0000088PuvQAE.png0690X0000088PulQAE.png0690X0000088PugQAE.png0690X0000088PubQAE.png0690X0000088PuRQAU.png

10 REPLIES 10
YJMoon
Associate III

I found something, but I can not be sure that this is the right answer.

​Is it a DMA2 problem?

Will this code work without errors if I change the uart port?

YJMoon
Associate III

I solved this problem.

My code was a problem.

I use rx_buff to ring or HAL_UART_Receive_IT function,

it works normally even if I transfer data quickly.

Martin KJELDSEN
Chief III

Hi @YJMoon​,

That's great news. Any issues with displaying that information in the TouchGFX GUI?

There was no problem in expressing without changing the screen.

However, when the screen is switched and data is transmitted at the same time, the value sometimes does not change.

I think I need to debug a bit more about this later.

Okay, let me know!

/Martin

ihsanoglu
Senior

Hi

I need your assistance,

I am trying to configure UART in interrupt mode, but whenever I recieve a character the program freezes

At the beginning I thought this is a flags issue .. but now I am lost .. I just want be able to call an interrupt rotuine on receive ..

I would really appreciate your help on how to configure it

I tested it

1. uart dma and ring buffer

2. Use HAL_UART_Receive_IT

to be.

Among them, I used HAL_UART_Receive_IT because the length of input data is fixed.

I'm not sure my code is correct ... but I release my code.

My board is stm32f746-disco

HAL_UART_Receive_IT (); function must be called to re-enable the interrupt.

Adding a ring buffer here will give you more flexibility.

uint8_t RecvOn;

uint8_t Usart1RxBuf[8];

int main(void)

{

 HAL_Init();

 __HAL_RCC_CRC_CLK_ENABLE();

 SystemClock_Config();

 MX_MPU_Init();

 MX_Common_Function_Init();

xTaskCreate(MODtask, "MODtask", 512 , NULL , 2, NULL);

.

.

.

vTaskStartScheduler();

while(1);

}

void MX_USART1_UART_Init (void)

{

  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;

  huart1.Init.OneBitSampling = UART_ONE_BIT_SAMPLE_DISABLE;

  huart1.AdvancedInit.AdvFeatureInit = UART_ADVFEATURE_NO_INIT;

  if (HAL_UART_Init (& huart1)! = HAL_OK)

  {

    Error_Handler ();

  }

}

void HAL_UART_MspInit (UART_HandleTypeDef * huart)

{

  GPIO_InitTypeDef GPIO_InitStruct = {0};

  if (huart-> Instance == USART1)

  {

    __HAL_RCC_USART1_CLK_ENABLE ();

    __HAL_RCC_GPIOB_CLK_ENABLE ();

    __HAL_RCC_GPIOA_CLK_ENABLE ();

    GPIO_InitStruct.Pin = GPIO_PIN_7;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed ​​= GPIO_SPEED_FREQ_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;

    HAL_GPIO_Init (GPIOB, & GPIO_InitStruct);

    GPIO_InitStruct.Pin = GPIO_PIN_9;

    GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

    GPIO_InitStruct.Pull = GPIO_NOPULL;

    GPIO_InitStruct.Speed ​​= GPIO_SPEED_FREQ_VERY_HIGH;

    GPIO_InitStruct.Alternate = GPIO_AF7_USART1;

    HAL_GPIO_Init (GPIOA, & GPIO_InitStruct);

    HAL_NVIC_SetPriority (USART1_IRQn, 7, 0);

    HAL_NVIC_EnableIRQ (USART1_IRQn);

  }

}

----------------------------------------------USART1_IRQHandler

void USART1_IRQHandler (void)

{

HAL_UART_IRQHandler (& huart1);

}

----------------------------------------------USART1_IRQHandler

----------------------------------------------freertos task

void MODtask(void* params)

{

 RecvOn=0;

 HAL_UART_Receive_IT(&huart1, Usart1RxBuf, 8);

 while(1)

 {

  if(RecvOn==1)

  {

   CRC16_rtu_check(Usart1RxBuf, u1_mb.data_size);

.

.

.

.

.

HAL_UART_Transmit(&huart1, u1_mb.u1_tx, u1_mb.frame_size, 20);

RecvOn=0;

HAL_UART_Receive_IT(&huart1, Usart1RxBuf, 8);

}

vTaskDelay(20);

}

----------------------------------------------freertos task

 void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)

{

 if(huart->Instance == USART1)

  {

   RecvOn = 1;

  }

}

does this code work ?

I am initializing my UART same as your code .. Polling mode is working great but whenever I want to use the interrupt mode I have the following problem

After calling HAL_UART_Receive_IT .. the microcontroller and program freezes whenever the UART receives anything

Also if I call HAL_UART_Receive_IT after I already sent something to the uController without receiving it the program freezes immediately

I need to use UART in interrupt mode .. do you have any suggestions ?

I just tested Push Button EXTI .. I am getting the same behaviour as soon as I push the button ..

This problem seems not to be about UART but about NVIC in general ..

Any ideas ?