I am presenting below an example of an Intel-hex frame (Fig-1, generated by LOD186.exe for 8086 Microprocessor) in order to explain the meanings of various fields of the frame. Please, note that every symbol/digit of the frame is transmitted/received as ASCII code. This frame does not contain LF/CR as the end mark which could have been added by the sender.
Figure-1:
Field-(a): There is the symbol (:), which has the ASCII code of 3AH. The IBMPC sends it to the trainer to indicate the start of the transmission of a frame.
Field-(b): 14 (14h = 20 decimal), indicates that the sender will transmit 20 bytes information bytes, which are contained in Field-(e).
It is not a fixed amount -- LOD186.exe accommodates 24 bytes. ASM51.exe accommodates 16 bytes, and Arduino IDE accommodates 16 bytes.
MICROCHIP STUDIO accommodates different values for different frames as is seen below:
:020000020000FC
:040000000395FECF97
:00000001FF
Field-(c): 100 (1000h) indicates the RAM/Buffer location (only the OFFSET) of the receiver from which the information byte of Field -(e) would start saving. This is to say that the byte 90h would be stored at location 01000h (0000:1000 for 8086) of the CSM. 20h would be stored at location 01001h and so on.
Field-(d): 00 (00h) indicates normal mode of transmission.
Field-(e): There are 20 (14h) bytes of information, which agrees with the declaration made in Filed- (b) of the frame.
Field-(f): D3 (D3h) is known as the Checksum Error (CHKSUM). This is the code, which the sender computes from all the data bytes of the Fields-(b), (c), (d) and (e) only and is sent as a last byte of the frame. This code allows the receiver to take decision as to the validity of the received data frame.
The receiver computes the CHKSUM in the following ways:
1. All the data bytes from Fields- (b) to (e) are added. The result is: 092Dh
2. The accumulated carry of the result is discarded. The rest is: 2Dh
3. All the bits are inverted (0010 1101 1101 0010): The result is: D2h
4. 01 is added. The result is: D3, which is the 2’s complement form of the lower byte of the sum, which is 2Dh in step-2 above.
The receiver accepts all the data bytes of a frame as they are coming from the sender. It adds up all the data bytes the first and the last one of a frame. The upper byte of the addition is discarded. The lower byte is added with the last byte of the frame and the result should be 00h and if so, the received frame is probably good. Otherwise, the receiver sends an error message to the sender.
===> The first 2-digit (in hex base, Fig-1) after the initial colon ( : ) specify the number of information bytes (Field-e of Fig-1) in the line/frame.
Yes! These are first 2-byte after the initial colon ( : ---> 3A) when talking in respect of the ASCII coded transmission/reception frame.
==> 3A31343130.............................4433 for the frame of Fig-1.