Microcontroller visualizes hex code

-April 27, 2000

In µC systems, information exchanges usually use the hexadecimal 1-2-4-8 format; output data also appear in this format. Reading the hex code is not a problem; several LEDs connected to the output lines can display the answer. The problem arises when you wish to observe the output data. Many engineers are unfamiliar with hex code and prefer to observe data in the common decimal format. If the value of the output data is less than 10, you can use an ordinary BCD-to-seven-segment decoder to visualize the hex code on an LCD or an LED display. But what do you do if the value of the output data is greater than 10W Unfortunately, no decoders can transform hex code into two seven-segment codes. Of course, you could configure such a decoder using a number of logic gates, but another simple and inexpensive option is available. The key to this option is using a low-end µC to transform the hex code into two BCD codes. In Figure 1, the data displayed ranges from 0 to 15. Thus, you need only 4-bit hex code, using four input and eight output µC lines.

Figure 1 uses the approximately $1 Motorola MC68HC705J1A, with 14 I/O pins. The input lines Pin B0 to Pin B3 receive the 4-bit hex code to be displayed. The µC-assembly program in Listing 1, converts the hex code into two BCD codes, which appear on lines Pin A0 to Pin A3 (units) and Pin A4 to Pin A7 (tens). These outputs drive the two standard BCD-to-seven-segment decoders, which, in turn, drive the common-cathode LED displays. You can use the same method for an expanded data range, but you need more I/O lines, decoders, and displays. For example, the 8-bit hex code covers the data range 0 to 255, but it needs eight input lines, 12 output lines, and three decoders and displays. Click here to download Listing 1 and the "include" file in line 3. (DI #2518)

Loading comments...

Write a Comment

To comment please Log In