cancel
Showing results for 
Search instead for 
Did you mean: 

stm32f7 uart rx interrupt mode running only once

Tp
Associate II

Hi,

we have custom stm32f7 board with debugger connected and we are configuring UART RX in interrupt mode. In main function code is like below and uart rx interrupt is working fine for only once.

uint8_t aRxBuffer[15];

if(HAL_UART_Receive_IT(&UartHandle, (uint8_t*)aRxBuffer, 15) != HAL_OK)

 {

  /* Transfer error in reception process */

  Error_Handler();

  }

From other similar forum threads,it is understood that it runs only once.it invokes following callback on serial command .

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)

{

 if((aRxBuffer[0] == 'c') && (aRxBuffer[1] == 'o')&& (aRxBuffer[2] == 'p') && (aRxBuffer[3] == 'y'))

   {

   usbcopyrequest =1 ;

   

   }

}

can i do following change to handle incoming rx interrupt at all times.

void HAL_UART_RxCpltCallback(UART_HandleTypeDef *UartHandle)

{

 if((aRxBuffer[0] == 'c') && (aRxBuffer[1] == 'o')&& (aRxBuffer[2] == 'p') && (aRxBuffer[3] == 'y'))

   {

   usbcopyrequest =1 ;

   

   }

 if((aRxBuffer[0] == 'c') && (aRxBuffer[1] == 'o')&& (aRxBuffer[2] == 'n') && (aRxBuffer[3] == 'f'))

   {

   confrequest =1 ;

   

   }

/* change*/

memset(aRxBuffer,'0',sizeof(aRxBuffer));

aRxbuf = &aRxBuffer[0];

if(HAL_UART_Receive_IT(&UartHandle, (uint8_t*)aRxBuffer, 15) != HAL_OK)

 {

  /* Transfer error in reception process */

  Error_Handler();

  }

}

0 REPLIES 0