| Electronic Components Datasheet Search |
|
TB026 Datasheet(PDF) 3 Page - Microchip Technology |
|
|
|||||||||||||||||||||||||||||
TB026 Datasheet(HTML) 3 Page - Microchip Technology |
|
3 / 6 page ![]() TB026 © 1998 Microchip Technology Inc. DS91026A-page 3 HEX FILE FORMAT Development tools from Microchip support the Intel HEX Format (INHX8M), Intel Split HEX Format (INHX8S), and the Intel HEX 32 Format (INHX32). The most commonly used formats are the INHX8M and the INHX32. These are the only formats discussed in this document. Please refer to Appendix A in the MPASM User's Guide (DS33014) for more information about HEX file formats. The difference between INHX8M and INHX32 is that INHX32 supports 32-bit addresses using a linear address record. The basic format of the hex file is the same between INHX8M and INHX32 as shown below: :BBAAAATTHHHH...HHHHCC Each data record begins with a 9 character prefix and always ends with a 2 character checksum. All records begin with a ':' regardless of the format. The individual elements are described below. • BB - is a two digit hexadecimal byte count repre- senting the number of data bytes that will appear on the line. • AAAA - is a four digit hexadecimal address repre- senting the starting address of the data record. Format is high byte first followed by low byte, the address is doubled because this format only sup- ports 8-bits (to find the real PICmicro address, simply divide the value AAAA by 2). • TT - is a two digit record type that will be '00' for data records, '01' for end of file records and '04' for extended address record (INHX32 only). • HHHH - is a four digit hexadecimal data word. For- mat is low byte followed by high byte. There will be BB /2 data words following TT. • CC - is a two digit hexadecimal checksum that is the two's complement of the sum of all the pre- ceding bytes in the line record. HEX File Preparation The checksum used to verify program memory con- tents is a 14-bit number calculated only on the program memory contents of a HEX file. The reason that only 14-bits is used is because the PIC16F87X has 14-bit wide program memory. The first step to obtaining the checksum is to get a com- plete HEX file that has all address locations specified. This can be easily accomplished in MPLAB by enabling the programmer, either PROMATE II or PICSTART PLUS, whichever one is available. Load the HEX file into MPLAB using the menus File -> Import -> Down- load to Memory. Then save the HEX file using File -> Export -> Save HEX File. Make sure that the Program Memory box is checked with a range of 0 to 8191 and the Configuration bits and IDs box are also checked. It is optional to check the EEPROM memory box depend- ing on you application. This will create a complete HEX file including all program memory, configuration word, IDs, and optionally EEPROM memory. The checksum provided by a programmer, such as PROMATE II or PICSTART PLUS, is not valid because the configuration word and device ID are included in the calculation. Therefore, a different program is required to calculate the program memory checksum. Once a complete HEX file has been obtained by the previously presented method, it must be processed and modified to contain the checksum. The program CHECKSUM.EXE, which is a DOS based program, reads in the HEX file, calculates the checksum, and outputs the new HEX file with checksum included. The checksum is calculated by: 1. Adding together the memory locations 0x0000 to 0x1FFE. 2. Mask off all but the lower 14-bits. 3. Take the 2's complement of Step 2. 4. Mask off all but the lower 14-bits. 5. Save this value into the HEX file at address 0x1FFF. The program ignores all configuration word, ID, and EEPROM memory information in the HEX file and dumps it to the output file unchanged. The output file can then be programmed into the PIC16F87X device. PICmicro Code The code used by the PIC16F87X to calculate check- sum uses 36 words of program memory and two data memory locations. The example code uses data mem- ory locations 0x7E and 0x7F to store the calculated checksum. These locations are shared across all banks. The user can optionally change these locations and add banking into the routine. Figure 2 shows the flowchart for the routine. The checksum is created such that by adding up all program memory locations, a 14-bit result of 0x0000 is obtained. Since the calcu- lation is done in 16-bits, the result will actually be 0x4000, but the upper two bits are masked off by the routine. Example 1 shows the code in MPASM to cal- culate the program memory checksum. If the program memory verifies, the routine returns a '1'. If a failure is detected, the routine returns a '0'. |
|
|
Link URL |
| Does ALLDATASHEET help your business so far? [ DONATE ] |
About Alldatasheet | Advertisement | Contact us | Privacy Policy | Link to Datasheet | Link Exchange | Manufacturer List All Rights Reserved©Alldatasheet.com |
| Russian : Alldatasheetru.com | Korean : Alldatasheet.co.kr | Spanish : Alldatasheet.es | French : Alldatasheet.fr | Italian : Alldatasheetit.com Portuguese : Alldatasheetpt.com | Polish : Alldatasheet.pl | Vietnamese : Alldatasheet.vn Indian : Alldatasheet.in | Mexican : Alldatasheet.com.mx | British : Alldatasheet.co.uk | New Zealand : Alldatasheet.co.nz |
|
Family Site : ic2ic.com |
icmetro.com |