AnsweredAssumed Answered

[STM32F746] UART Interrupt using CubeMX generated code

Question asked by OH.YOUNGJAE on Jan 20, 2017
Latest reply on Jan 20, 2017 by T J

I want to get UART Interrupted data to vary LED blinking speed.

For example, If I send 1 then speed 100ms or send 2 then speed 200ms.

 

I made a cod using CubeMX and Interrupting with just pressing "Enter" works perfect(Not sending any data)

(I pressed "Enter" 3 times in Line Sender)

but If I send some character like below, It iterrupts just one time and never interrupt again with my further interrupt action.

 

Here is my Code.

First of al,l I am getting Terminal "printf" output into Serial using code below in function "HAL_UART_MspDeInit" in usart.c.

/* USER CODE BEGIN 1 */

#ifdef __GNUC__

/* With GCC/RAISONANCE, small printf (option LD Linker->Libraries->Small printf set to 'Yes') calls __io_putchar() */

#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)

#else

#define PUTCHAR_PROTOTYPE int fputc(int ch, FILE *f)

#endif /* __GNUC__ */

/**

* @brief Retargets the C library printf function to the USART.

* @param None

* @retval None

*/

PUTCHAR_PROTOTYPE{

/* Place your implementation of fputc here */

/* e.g. write a character to the EVAL_COM1 and Loop until the end of transmission */ HAL_UART_Transmit(&huart1, (uint8_t *)&ch, 1, 0xFFFF);

return ch; }

/* USER CODE END 1 */

 

in my main.c

while (1)

{

HAL_Dealy(100);

printf("Hello!\r\n");

}

in stm32f7xx_it.c

viod USART1_IRQHandler(void)

{

/* USER CODE BEGIN USART1_IRQn 0 */

if ((_HAL_UART_GET_FLAG(&huart1, UART_FLAG_RXNE) != RESET) && (__HAL_UART_GET_IT_SOURCE(&hurat1, UART_IT_RXNE) != RESET)

{

printf("I will Interrupt You!!!\r\n");

}

__HAL_UART_CLEAR_PEFLAG(&huart1);

/* USER CODE END USART1_IRQn 0 */

HAL_UART_IRQHandler(&huart1);

}

 

Do you have any idea what went wrong here?

Outcomes