In order to parse a hex file you need to identify relevant format. Assuming you are using MPLAB X it is highly likely that the file format of interest is SQTP. Below are some fields an related descriptions. You will need to do some research to validate if the information below is relevant for your application.
Field |
Description |
Field 1 |
Start Code – 1 character This character is an ASCII colon ‘:’ |
Field 2 |
Byte Count – 2 hexadecimal digits These two digits indicate the number of bytes (HEX digit pairs) in the data field. The maximum byte count is 255 (0xFF). For example, 16 (0x10) and 32 (0x20) byte counts are commonly used. |
Field 3 |
Address – 4 hexadecimal digits These four digits represent the 16-bit beginning memory address offset of the data. The physical address of the data is computed by adding this offset to a previously established base address. This provides memory addressing beyond the 64-kilobyte limit of 16-bit addresses. The base address, which defaults to zero, can be changed by various types of records. Base addresses and address offsets are always expressed as big endian values. |
Field 4 |
Record Type – 2 hexadecimal digits, 00 to 05 These two digits define the meaning of the data field. For SQTP, only three types are used; 00, 01, and 04 (see Table 1-1). |
Field 5 |
Data – a sequence of n bytes of data Data is represented by 2n hexadecimal digits. Some records omit this field (n equals zero). The meaning and interpretation of the data bytes depends on the application. |
Field 6. |
Checksum – 2 hexadecimal digits These two digits represent a computed value that is used to verify the record has no errors by ensuring the summation of each of the bytes in the line add upChecksum – 2 hexadecimal digits These two digits represent a computed value that is used to verify the record has no errors by ensuring the summation of each of the bytes in the line add up add up to 0. |
Additional UART is a communication protocol. UART will not parse the file. You will be develop software the parse the hex file. To the best of my knowledge the microcontroller will need a binary file.
Lastly this is a solved problem. There are plenty of open source resources that will minimize your work.
Per comment below, if are using Kiel as IDE you can fromelf to create bin file.

fromelf.exe --bin --output=user_application.bin User_Application\User_Application.axf
References