I have had mixed success with HSERIN and HSEROUT. You certainly MUST set the defines for HSER_TXSTA, HSER_RCSTA and baud rate. I think you also need to manually clear framing and overrun errors for complete success. Maybe also to tie the input high or low with 4k7. I never found out why the command was unreliable and so I gave up on HSER and went for SERIN/OUT and SERIN2/OUT2 which are software UARTS. They take a little more code and time but they have been absolutely reliable in my usage.

I also send and receive HEX from time to time. I use the bit masking technique.

Assume the 8 bit value for A has been received by your favourite serial input routine, such as SERIN. Further assume the upper 4 bit nibble is B and the lower 4 bit nibble is C

Find the upper nibble
B = A >> 4 ' here the lower four bits 'fall off' and the new incoming upper bits are zeros.
More properly perhaps
B = A >> 4 & %00001111

Isolate the lower nibble
C = A & %00001111 'here the upper4 bits are masked to zeros

To build a new A in the reverse hex/nibble order to that received.

A = (C << 4) | B 'this is the bitwise addition of the upper and lower 4 bits to make a new 8 bit byte.


HTH
BrianT