ENCYCLOPEDIA OF RADIO ELECTRONICS AND ELECTRICAL ENGINEERING How to check a HEX file. Encyclopedia of radio electronics and electrical engineering Encyclopedia of radio electronics and electrical engineering / Microcontrollers Many radio amateurs, trying to repeat this or that device on a microcontroller according to a magazine publication, often encounter difficulties that are inexplicable at first glance. It would seem that the health of the microcontroller is beyond doubt, and the programmer is in perfect order, and the device is assembled exactly according to the scheme, but it refuses to work as it should. In such a situation, complaints about the author of the development are not uncommon - he presented, they say, an inoperable program! In fact, in the vast majority of cases, things are different. The mistakes made during the manual input of the HEX-file of the program into the computer by its "printing" on the pages of the printed edition are to blame. Much less often there are failures when copying files from floppy disks or "downloading" them from the Internet. How to check a HEX file? The answer to this question is in the published article. Any, at first glance, the most harmless, at first glance, typo in the HEX file leads to the execution of an incorrect command by the microcontroller (MC), often completely distorts the specified algorithm of its operation and can lead to completely unpredictable behavior of the manufactured device. Not a single most qualified specialist in this situation will be able to accurately indicate the location of the error by external signs. It remains to check the HEX file with the original very carefully and repeatedly. The peculiarity of our psyche is that, having checked something once, we are subconsciously convinced of our own infallibility, and during repeated checks we often miss what we did not notice the first time. Therefore, it is useful to have an assistant who, without even delving into the essence of the work, will carry out "independent control". In no case should you leave without checking the texts of programs read by the scanner with subsequent recognition using the FineReader program and the like. Practice shows that character recognition errors are inevitable even with very high quality printed text. When entering HEX files manually (from the keyboard) or their electronic versions obtained by scanning, the following most often happens:
The most harmless of these defects is the last one. Unlike others, it does not affect the performance of the program. The same in most cases can be said about the violation of the order of the lines. However, programmers who provide strict control over the correctness of the input data can still reject a file with such errors. It must be said that the control of the correctness of the structure of the HEX-file in the process of reading it from the disk is performed by the software of very many programmers. Certain possibilities for this are inherent in the very structure of such a file, which can be read, for example, in the author's article "Development and debugging of devices on the MK" ("Radio", 2001, No. 5, p. 19). The trouble is that the programmer often reports only the fact that an error has been detected without any details, leaving the user to figure it out for himself. In this case, the defective file often turns out to be completely or partially loaded into the programmer, and if you carelessly give the "Programming" command, erroneous data will be transferred to the MK's memory. After that, verification will be successfully completed (verification of the contents of the memory of the MK and the programmer) and the user will get the impression that everything is in order. In this regard, the program PonyProg (version 2.05 and earlier) behaves very dangerously. In addition to HEX, it provides several other input file formats, and when loading, it tries to choose the right one on its own. Not correctly recognizing the file format with errors, she still enters it as binary. On fig. 1 shows the view of the PonyProg programmer window after such input. The memory contains not machine command codes, but ASCI codes of letters and numbers that make up a text HEX file. Naturally, according to such a "program" MK will not work. The view of the same window after entering the error-free file identical to the first one is shown in Fig. 2. Note that the programmer did not give any error messages or about automatically determined file format in both cases. The program will be able to help find and correct errors in the HEX file before entering it into the programmer. CheckHEX. With its help, you can create a new HEX file by typing its contents on the computer keyboard. In the latter case, the verification takes place simultaneously with data entry. The data window of the CheckHEX program after entering a HEX file containing several errors is shown in Fig. 3. In its upper part, on the left, the current coordinates of the cursor are displayed, showing where the character will be entered when the key is pressed. On the right there is a window, by clicking on it with the "mouse", you can cancel or re-enable error checking at any time. Blocking control can be useful for the duration of manual data entry, otherwise each incomplete line is accompanied by a lot of messages that only distract attention. The warning and error message window (Fig. 4) is located below the main one. Messages beginning with the word "Information" only indicate the special status of certain lines of the HEX file. In this case, there are two such lines. The first of them is optional, since in its absence, the address count will start from zero. Such lines (there may be several of them in different places in the file) allow you to address more than 64 KB (32 Kwords) of memory. It is their presence that distinguishes HEX files of the INX32 format from those of the INX8M format. Line 25 marks the end of the HEX file. If any data is after it (line 26), it will not be accepted by the programmer. This can be used, for example, to place a text comment in a HEX file. In the example, line 20 of the source file was simply moved here, which remained empty. In principle, the presence of empty lines in a HEX file is acceptable, but some programmers may still consider them errors. The CheckHEX program, just in case, warns about this. Note the checksum error message on line 3. It may be the result of a mistyped character in any (except colon) character of the string, which should be checked very carefully. The "correct" checksum given in brackets is useful if one or more characters of the string have been changed intentionally (for example, to correct an actual program error). In this case, the error is the result of entering the number 8 instead of the letter B. The nature of the error in the fifth character of the fourth line is clear. We only note that to facilitate the visual search for errors, the text font in the main window does not contain Cyrillic characters, their place is occupied by characters that have nothing to do with the correct ones. However, Russian letters are presented in error messages. To the right of the data window, there is a window showing the picture of filling the MC memory with codes from the analyzed file. A fragment of this window is shown in Fig. 5. White color corresponds to free cells, blue or red - occupied. The explanatory inscriptions in the figure (they are not in the real window) refer to the typical memory distribution for RIS controllers, for other MKs and EPROMs it can be completely different. By moving the mouse cursor inside the window, you can determine the address of any of the cells displayed there. In this case, the cursor (crosshair in the upper right part of the window) points to the byte at address OOSON - junior in the two-byte word at address 0060H. Of course, a user who has not developed a downloadable program and has not carefully analyzed it, as a rule, does not know which cells should be occupied and which should not. Nevertheless, it makes sense to pay attention to gaps in the continuous sequence of occupied cells and make sure once again that they did not appear as a result of errors, as in the case under consideration. The red segment indicates that the codes entered at these addresses have been encountered in the file more than once. In the example (see Fig. 3), the seventh and eighth lines are identical. If the duplicate row is the result of inattention during manual data entry, it can be deleted. But more often the mistake made in the address part of the line (characters from the fourth to the seventh) is to blame. In such a case, not only the codes at erroneous addresses will be distorted, but the memory area to which the given line originally belonged will also remain undefined. All this needs to be checked again and again. In conclusion, we note that there are three control buttons in the CheckHEX program window: - create a new HEX file; - open and check existing ; - save the created or edited file. When you try to upload or create another file without first saving the modified version of the old one, the program always reminds you of the need to do so. The same happens before the program terminates. Author: A. Dolgiy, Moscow See other articles Section Microcontrollers. Read and write useful comments on this article. Latest news of science and technology, new electronics: Machine for thinning flowers in gardens
02.05.2024 Advanced Infrared Microscope
02.05.2024 Air trap for insects
01.05.2024
Other interesting news: ▪ Smartphone Fujitsu Arrows A 202F ▪ Three-dimensional image on the monitor screen News feed of science and technology, new electronics
Interesting materials of the Free Technical Library: ▪ site section Electric motors. Article selection ▪ article Facts speak for themselves. Popular expression ▪ What were the features of the emergence of the Ancient Roman state? Detailed answer ▪ article Devices on logical elements. Radio - for beginners
Leave your comment on this article: All languages of this page Home page | Library | Articles | Website map | Site Reviews www.diagram.com.ua |