how to Clear RxBuffer in HAL_UART_Transmit_IT
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-08-31 3:12 PM
Posted on September 01, 2016 at 00:12
Hi,
I have been wokring on STM32F030 Discovery.I have initialized UART. Whenever I send data from my PC to STM32. It adds the data into previous data. For example if I send ''123'' and next time I send ''456''. The whole string would be like ''123456'', even though they both are different strings. How to clear the buffer? I tried clearing the buffer, but it clear everytime the UART interrupt occurs and clear everything and shows nothing.Please help?Here is my code&sharpdefine BUFFER_SIZE 9void USART2_IRQHandler(void){ HAL_UART_IRQHandler(&huart2); uint8_t i; HAL_UART_Receive_IT(huart,(uint8_t*)ReceivedData,BUFFER_SIZE); for (i=0;i<BUFFER_SIZE;i++) { ReceivedData[i]=0; //clear Rx_Buffer before receiving new data } } #uart #!stm32 #stm32 #stcubemx #hal
Labels:
This discussion is locked. Please start a new topic to ask your question.
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2016-09-01 4:44 AM
Posted on September 01, 2016 at 13:44
Hello mattoo.anuj,
Can you post your main.c code? Have you tried clearing the buffer from the ''HAL_UART_RxCpltCallback()'' in main.c to process the string once the UART Rx transfer is complete? I am sure that is not the most efficient way, but can help move you to functioning code.