STM32F051K8, I2C and UART Communication Issue
Hi,
I am trying to receive voltage from an external ADC, MCP3421 using I2C. These values are then transmitted over USART to be viewed by the user ranging from (-2.048 to 2.048). The MCU I am using is STM32F051K8.
The problem that I am facing is that the program runs fine for 4-5 hours but then returns garbage value on the uart. eg. 262.7 or 568.7. If I reset the communication it starts working fine again.
I am using FreeRTOS where one task gets the value from the ADC and stores it in a variable that is the passed over uart to be viewed. And another task waits for user to send a string so that the uart (HAL_UART_Receive_IT(&huart2, (uint8_t *)rxBuf, 2);) can start transmitting.
Code using TrueStudio Atollic.
a snippet of my code:
if(strcmp(rxBuf,"y#")==0){
sprintf_(txBuf, "%2.4f\n",sendvar);
HAL_UART_Transmit_IT(&huart2, (uint8_t *) txBuf,8);
}
Thanking you in advance.