The log output is so messy through the UART COM port. How can i avoid it???
In TeraTerm try setting the NewLine Receive to Auto. If that doesn't help you can try the other settings to see which helps.
Try replacing all the occurrences of '\n' with '\n\r' in the entire code base.
Retrieving data ...