uart giving only null
The problem is not the ”extra” ’H’ you see, but what you don’t see!
I’m guessing your transmitter side send a “HELLO\r\n” (that’s a regular “Enter”, or a CR=0x0D (13) followed by a LF=0x0A (10)).
Your ‘uart_gets()’ waits until it sees a CR (13), it replaces it with NULL and returns, but in UART’s receive buffer there will be a LF (10) char left for the next time you call ‘uart_gets()’, and that char will be retrieved as the first element in your string, before the H.
You’ll have to deal with all the received characters, and flush them (and no, SBUF=0 won’t do, you’ll have to do a dummy read instead).
Please don’t mind me saying that your coding style just begs for errors. Although correct, your choice to name formal parameters with the same name as global ones is very confusing, to not mention the obfuscation of the rest of the code.
I hope you realize that this will only work in this particular case and in no way should you use this code as a template for general purpose.
Arthur