User's Guide

Home About the
Simulator

User's
Guide

Installation
Instructions
Examples Contact
Us
The Fundamental
Simulations
Beginner's Guide
to the 8051
Site Map
 
User's Guide
 

 
 

 
New Features!
 
Get the latest EdSim51 version
 


 LCD Module

A simulation of the popular Hitachi HD44780 LCD module has been implemented for the EdSim51 Simulator. The user can toggle between the LED display and the LCD display by clicking on the blue button above the display. And now CGRAM has also been implemented. Find out more.




Zoom
For high resolution monitors, click on the zoom button. The zoom button is located below the red Exit button.
 

 
Keypad Modes
Now the user can select from three modes of operation:
  • Standard - any number of keys can be closed at the same time.
  • Pulse - once the mouse button is released the key reopens.
  • Radio - in radio mode only one key at a time can be closed.
 
 
Keypad And External 1 Interrupt
Until now the keypad could only be implemented using busy-waiting. It can still be implemented in that manner, but it can also be used together with the 8051 external 1 interrupt pin, P3.3.
Note: this pin, P3.3, is also used by the display-select decoder, therefore multiplexing of the 7-segment displays cannot be implemented together with the keypad interrupt. To multiplex the displays and use the keypad at the same time, the keypad must be implemented using busy waiting.
 
More information on the keypad modes and the keypad interrupt

 

 

 

 


 
Intel HEX Reader/Writer
  You can now save your source code in Intel HEX format. Or you can write C code for the 8051 using one of many available 8051 C compilers, then import the HEX code into the EdSim51 Simulator. Find out more.
 

 
External UART Baud Rate Selector
  Originally the external UART's Baud rate was set at 62,500. Now the user can choose from a list of Baud rates. This allows the student to experiment with different Baud rates and to learn how the 8051's serial port, Timer 1 and the SMOD bit are used together to generate the required Baud rate (for more information on the 8051 serial port, see our Beginner's Guide to the 8051 - Serial Port).
 
The default Baud rate is 19200. The user can select from a list of standard Baud rates, as shown above.
 
Read more on the UART
 

 
Simulator Window Update
As with many microcontroller simulators, EdSim51 allows the user to either step through a program, executing a single instruction per step, or to run the program continuously. In the original EdSim51 design, when running a program, the simulator would execute one instruction, update the screen, pause for a quarter second, then proceed with the next instruction and so on. This allowed the programmer to observe changes in the hardware and registers for each executed instruction. However, while this is very useful for debugging, it meant the programmer would need to wait a long time for things to happen (examples: data transmitted on the serial port to appear on the UART, an LED flashing at half second intervals, etc).
 
  The best of both: now the programmer has the choice. Using the Update Freq. drop down menu (shown above) the programmer can choose how often the screen should be updated. The choices are: update the screen after every instruction execution (the default), after 100, 1000, 10,000 or 50,000 executed instructions. The programmer can change from one frequency to another while the program is running.
 
Find out more.
 
 

 
The Microcontroller Panel
 
 
A screenshot of the microcontroller panel. This gives the user access to all the 8051's registers and data memory.
Boxes that are white can be edited directly. Those that are grey cannot. For example, the port latch bits can be edited directly by the user, but the port pins are controlled by the external peripherals and the port latches and cannot be edited. Also, the program counter is not editable.
When the mouse pointer is left to hover over one of the register labels, the register's address appears, as shown opposite for the PCON register.  
 
 
The Bitfield
In the above image, the individual bits for the accumulator are shown (ACC). The user can enter any address or SFR name in the blue box (replacing ACC) and the bits for that given address will then be displayed. Also, if you let the mouse pointer hover over one of the bits momentarily, the bit's description is displayed, as shown below:
 
  The bit field for the TMOD SFR is shown. Notice bit 2 is the counter/timer bit. Also notice the background is grey. This is because the TMOD register is not bit-addressable - the user cannot alter these bits directly.
     
  The PSW is bit-addressable, therefore the background of each bit is white and the user can change any of the bits directly.
     
  The bitfield can be used to see the bit pattern of any address in RAM (0 to 7FH) by typing the address in the blue box. If the location is bit-addressable, the bit backgrounds are white and the user can alter any of the eight bits.
     
  As with SFRs, if the location is not bit-addressable the backgrounds are grey.
 
 
Data and Code Memory
By default, data memory is displayed. Any address in RAM (00H to 7FH) can be altered by entering the address in the blue box (labelled addr) and then entering the desired value in the box to the right (labelled value).
 
Displaying Code Memory
 
Code memory can also be examined and edited, as shown in the image above. To switch between data memory and code memory the user clicks on the button that is labelled Data Memory when data memory is displayed and Code Memory when code memory is displayed.
The first 127 bytes of code memory are displayed. To view another area of code memory, enter the start address in the blue box. The 127 bytes from the start address onwards will then be displayed. Again, like data memory, the address specified in the blue addr box can be altered by entering a value in the value box. However, it should be noted that this will result in the machine code and the assembly program being different.
In the image above, the assembly code that generated the machine code (as displayed in code memory) can be seen on the right.
 
 
Update Freq.
The user can choose to either step through a program (executing a single instruction per step) or run the program continuously. When running a program, the rate at which the screen updates is determined by the setting in the Update Freq. menu.


Using the Update Freq. drop down menu the programmer can choose how often the screen should be updated. The choices are: update the screen after every executed instruction (the default), after 100, 1000, 10,000 or 50,000 executed instructions.

The programmer can change from one frequency to another while the program is running.

 
 
 

 
The Assembly Code Panel
 
 
A simple assembly program is shown in the assembly code panel above. This program runs in a continuous loop, displaying the numbers 0 to 9 and back to 0 on the first 7-segment display. A snapshot of its execution can is shown opposite.  
 
When the background of the assembly code text area is white is it editable. The programmer can write code directly here, or can load a program from file using the Load button (dealt with in the next section).
 
When the program is ready for testing, the user can either click on the Step button to execute instructions one at a time, or on the Run button to run the program continuously. Either way, the program will first be assembled. If an error in the code is discovered, a message is displayed (with a red background) and the line with the error is highlighted in red.
 
If the code assembles without errors the text area's background changes to grey, if stepping through code, or blue if running the code continuously. The code cannot be edited at this point.
 
If you want to go back to editing your code, simply click on the Reset button.
 
 
Load and Save
The user can write code directly into the text box when it is in edit mode, or an existing program can be loaded from a file using the Load button. Similarly, code in the text box can be saved to file using the Save button.
 

There are two file types handled. The first is plain-text. Assembly programs are saved as regular plain-text files (often called text-only) and usually with .a or .asm file extension. By default, this is the format used when saving your source code in the EdSim51 Simulator.

 
The other file type is Intel HEX. The user can select to save a file in HEX format by choosing Intel HEX Files from the
Files of Type:
menu in the Save dialog box. Find out more on loading and saving Intel HEX files.
 
 
To make the simulator more user-friendly, the last directory accessed (either through loading a file or saving a file) will be remembered. Therefore, the next time the user opens a file dialog box by clicking on either the Load or Save buttons, the dialog box automatically opens in the last directory visited.
 
Copy and Paste
You can select code in the assembly text area and copy it to the system clipboard using the Copy button, the same as you do in your word processing package. This can then be pasted elsewhere in the assembly text area, using the Paste button (if the text area is editable - white background - if it is not, click Reset). Or you can paste the selected text into some other application (such as your word processor). Similarly, you can copy text from another application and paste it into the assembly text area.
 
 
A Few Notes on the Assembler
The 2-pass assembler with the EdSim51 Simulator is not a full-blown assembler. It does not link multiple files and only some of the directives you might expect are implemented. However, we feel it is more than adequate for the beginner. Below is a list of its features:
 
  • All of the 8051 instructions are implemented.
  • JMP rel equates to either SJMP rel or AJMP rel. LJMP rel must be programmed explicitly.
  • Similarly, CALL equates to ACALL. LCALL must be programmed explicitly.
  • SET and EQU directives are implemented.
  • ORG is implemented.
  • USING directive (states which register bank is being used) is implemented.
  • ARn equates to the register address, as specified by USING (if the register bank is not specified prior to ARn's use, register bank 0 is assumed).
  • SFR names and SFR bit names equate to the appropriate address.
  • HIGH followed by an operand in brackets equates to the high byte of the operand.
  • LOW followed by an operand in brackets equates to the low byte of the operand.
  • Labels are followed by a semicolon.
  • The default for numerical values is decimal. Hex values can be entered by appending H after the number, or placing 0x before it. If H is used, the number cannot begin with a letter (example: F5H must be written as 0F5H). Binary values are entered by appending B after the number (as shown in the image below).
  • The assembler is not case-sensitive.
 
Debugging
  Regardless of whether the code is running or being stepped, once the code assembles without errors, the address of each instruction is displayed to the left.

When stepping through the code, the instruction that was just executed is shown in the grey box at the top, together with the instruction's address
(example shown: Executed 0x2A: MOV 90H, A).

The next instruction to be executed, its address is highlighted. (002CH).

Note the background colour of the assembly text box in the image: grey. This means the code is being stepped. If it was running the background would be blue.
 
Breakpoints
A breakpoint can be set by double-clicking the instruction's address, as shown in the image below:
 
 

Setting a breakpoint: When stepping through the code, move the mouse over the address of the instruction and double-click.

When the breakpoint is set the vertical bar (|) immediately to the right of the address is replaced by a star (*), as shown below:

 
 
 

Removing a breakpoint: A breakpoint is indicated by a star (*). To remove the breakpoint, move the mouse over the instruction's address and double-click. The * is replaced by |.

 

Alternatively, you can remove all breakpoints with one click of
.

When the program is running and a breakpoint is encountered execution halts just before that instruction. In other words, the next instruction to be executed will be the breakpoint instruction. The programmer can then step through the code, or run the program, from that point.

 
 

 
The Peripherals
 
The Peripheral Panel
 
The peripherals are:
  • ADC
  • Comparator
  • Four 7-segment LED Displays
  • UART
  • Keypad
  • LED Bank
  • DC Bi-directional Motor
  • Switch Bank
  • DAC (output displayed on oscilloscope)
 

The image shows what is connected to each of the 32 port pins.

Port Pin Connections
 
The logic diagram below gives details of the peripheral interfacing.

EdSim51 Simulator Peripheral Logic Diagram
 

The LED Bank, DAC and the 7-segment Displays
 

As can be seen in the diagram below, the LED bank, the DAC inputs and the 7-segment display data lines all share port 1.

The selection of which of the four displays is enabled is done via P3.3 and P3.4. These port pins are applied to a 2-to-4 line decoder, the outputs of which are applied to the base of transistors that enable/disable the displays.
 
Logic diagram showing the LED bank, DAC and 7-segment display connections only.
 
The decoder is enabled via a logic 1 on P0.7. This pin is also applied to the DAC WR input, which is active-low. Therefore, to write data to the DAC the programmer disables the displays, which also has the effect of enabling the DAC's data lines. Data can then be written to the DAC. Whatever is on the inputs when the WR line is taken high is stored in (or written to) the DAC's internal register and remains there after the WR line is taken low. The analogue output for this data will be displayed on the scope until the next time WR is taken high and a new value is placed in the internal register.
The keypad can be implemented using the external interrupt 1 line (see keypad), but not while also multiplexing the 7-segment displays. This is because the external interrupt 1 line (P3.3) is also used by the display decoder (see logic diagram above). Therefore, keypad interrupt and multiplexing the 7-segment display cannot be used at the same time - the keypad AND gate should be disabled.
An example of the DAC in action is shown below:
 
   
Ramp generated via DAC appears on scope.
 
Code for Ramp Generation
 
LED Bank and the
7-segment Displays Panel
 
The code that generated the above ramp is also shown. The DAC's WR input is taken low permanently while the value in the accumulator is sent to the DAC's inputs, increased by 8 and then sent to the inputs again, and so on.
 
 

 
 The LCD Module
 As can be seen in the logic diagram below, the LCD Module also shares port 1 with the LEDs and DAC. 
 

Logic diagram showing the LED bank, DAC and LCD module connections only.
The user can switch between the 7-segment display and the LCD module, as illustrated, by clicking on the blue button above the display.

<==>
The LCD module is a simulation of the Hitachi HD44780 and is interfaced to the 8051 in 4-bit mode. P1.7 through P1.4 are connected to DB7 through DB4, while P1.3 is connected to the register-select pin and P1.2 is connected to the enable pin. Notice the read-write pin is connected to ground - the module can only be written to.
Details of the pin functions and the instructions for the LCD module are given below. For details on how to communicate with the module, see HD44780.pdf and some sample programs.

Reading: Instructions for reading from the module have not been implemented.
Keypad Interrupt: As explained above, the keypad interrupt cannot be used together with the 7-segment display because both share P3.3. However, as can be seen in the logic diagram here, the LCD module does  not use P3.3. Therefore, keypad interrupt can be used at the same time as the LCD module.
Character Blinking: Because the simulator does not run in real-time, it would be hard to know if the module was blinking. Therefore, if the programmer sets the module to blinking (see Display on/off controlinstruction below), the cursor position character alternates between blue text with red background and red text with blue background. In this way the programmer knows at a glance if the module is in blinking mode (when not in blinking mode, all characters are black with grey background).

The enable pin (E, connected to P1.2) is negative-edge triggered. On a negative-edge on E, the module reads the data lines DB7 - DB4.

4-bit Mode: As can be seen in the logic diagram above, the module is interfaced with the 8051 in 4-bit mode. This means the module's lines DB3, DB2, DB1 and DB0 are not used. The 8-bit instruction or data must therefore be sent in two 4-bit nibbles. The high nibble is sent first, followed by the low nibble. When the enable pin is taken high and then low, this causes the module to read the pins DB7-DB4 and store them in either the IR (if an instruction is being sent - ie: RS = 0) or the DR (if data is being sent - ie: RS = 1).
Initially, the module is in 8-bit mode and must be set to 4-bit mode by the programmer before any other communications with the module are attempted. This is done by sending the appropriate Function Set instruction (see instruction set below).
Why send Function set twice? As stated, the module is initially in 8-bit mode,  therefore the first instruction sent to it is read as an 8-bit instruction (as if DB3 - DB0 were in use). If the correct instruction is sent (with DL - on DB4 - set to zero, indicating 4-bit - see below), then the module 'knows' it is being set to 4-bit operation and it reads instructions and data in two 4-bit nibbles from then on.
Because it reads the high nibble first, the Function set high nibble must be sent again, followed by the low nibble.
For more information, see pages 39 and 42 of HD44780.pdf. The example on page 42 is for a 1-line display, but it nonetheless explains clearly how to initialise and communicate with the module in 4-bit mode.

2-line, 5 X 8 Font: The low nibble of Function set must be sent with N = 1 (setting the number of lines on the display to 2) and F = 0 (setting the font to 5 X 8 dots).
Function Set Incorrectly: The programmer must set the module to 4-bit, 2-line, 5 X 8 font. The simulation of the HD44780 is implemented for 4-bit, 2-line, 5 X 8 font only. However, the programmer is still expected to write the code that sets the module in this mode. If the mode is not set correctly, an error message stating such is displayed, as shown here. The programmer must then reset the simulator, modify the code and try again.


LCD Module Instruction Set

CGRAM
CGRAM stands for character generator RAM. The module's ROM contains the ASCII character set. For example, the ASCII code for the letter W is 87, so stored in location 87 in the module's RAM is the pattern for W. This makes it relatively easy to write text to the display. The following code extract illustrates this point:

    MOV A, 'W'
    CALL sendCharacter    ; a subroutine that sends the data in A to the LCD module's DDRAM

When DDRAM receives a character, the corresponding pattern from ROM is displayed.

Note in the ASCII set, the first seven locations are used for control characters. These characters are not applicable to the LCD module, therefore these locations are reserved for CGRAM instead. When a value in the range 0 to 7 is sent to DDRAM, instead of displaying a character from ROM, the corresponding character from CGRAM is displayed.
This means the user can create eight custom characters. The characters are programmed into CGRAM by pointing to CGRAM (instead of DDRAM) and then sending data to the module the same as when sending data to DDRAM.

If you look at the instruction set above you will see there is a Set CGRAM address instruction. Note the address is six bits in length - we will discuss these six bits shortly.
Also notice there is only one instruction for writing to the module. To write to CGRAM, you must first ensure the AC (address counter) is pointing to CGRAM. You do this by calling the Set CGRAM address instruction. As with writing to DDRAM, the AC is incremented (or decremented, depending on the increment/decrement setting) after each write to CGRAM.

It was mentioned above that ROM contains the ASCII set. This is not altogether true. There are instances where the character in ROM does not correspond with ASCII. At location 92 you would expect to see the \ symbol. Instead there is ¥ (probably because the HD44780 was developed in Japan). At location 126, instead of ~ in location 126 there is a right arrow symbol, followed by a left arrow symbol in location 127.

So, if you want to display the \ symbol, for example, you will first need to create it in CGRAM. You can choose any of the eight CGRAM locations, but let's say we wish to put \ in location 2.
Each character is made up of eight rows, with five dots in each row. You write the pattern for each row to CGRAM, one row at a time. The row's pattern is made up of 1s where dots are to be visible and 0s where dots are to be invisible.

The six CGRAM address bits are split into two parts. The top three bits determine which of the eight CGRAM characters is being written to, while the bottom three bits determine which of the eight rows of this character is being written to.

CGRAM Character Address (binary) Row Address (binary)
Value Written to CGRAM
010
010
010
010
010
010
010
010
000
001
010
011
100
101
110
111
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
00000B = 00H
10000B = 10H
01000B = 08H
00100B = 04H
00010B = 02H
00001B = 01H
00000B = 00H
00000B = 00H

The three character bits and the three row bits make up the 6-bit CGRAM address.
Note that the top row is row 0 while the bottom row is row 7 (111B). You can use the bottom row when creating a custom character, but it is not advisable to do so, especially if you intend using the cursor as well.

The example above shows how to create the \ symbol in CGRAM location 2. You start by setting CGRAM address to 2, then send the pattern for the character's first row to CGRAM (in this case, 00H). The AC will automatically increment to point to the next row. You then send the pattern for that row (in this case, 10H), and so on for all eight rows.

Once completed, you can then display your new character by setting the DDRAM address to some value, then send the number 2 to DDRAM and your new character in CGRAM location 2 will appear on the display.

You might then write a test, as shown below, to ensure the correct symbol is displayed when writing \ to the LCD:

            ... ; data to be sent to LCD has been placed in A
            CJNE A, #'\', skip                        ; if A does not contain \ symbol, skip next line
            MOV A, #2                                  ; replace \ with location of \ in CGRAM
skip:    CALL sendCharacter                 ; call the subroutine that sends the contents of A to the LCD


For complete instructions on how to program the LCD module, see HD44780.pdf.



The Switch Bank and the ADC
 
 

When a switch is open a logic 1 appears on the port pin (via the pull-up resistor) while closing the switch connects the pin directly to ground - logic 0.

The switch bank and the outputs of the ADC are applied to port 2. Therefore, it should be noted that when the ADC is being used the switches in the switch bank should all be open (in the simulator, the switches are blue when they are open).
If a switch is closed it doesn't matter what the ADC tries to put on that line, the line is held low because it is connected directly to ground through the closed switch.

Logic diagram showing the switch bank and ADC connections only.

 
  The outputs of the ADC are tri-state: the RD line, which is connected to P3.7, must be low for the ADC reading to appear on the outputs.
The WR line (connected to P3.6) is used to initiate a conversion. As it is positive edge triggered, it must be taken low and then high to start a conversion.
When the conversion is complete the INTR line goes low (and remains low until another conversion is initiated). This line is applied to the external 0 interrupt line, INT0. In this way, the 8051 can be interrupted by the completion of an ADC conversion.
Switch Bank and the ADC Panel
 
The function of the ADC pins are summarised in the following table:
Pin Function
RD Enables the tri-state outputs, when logic 0.
WR On a positive edge, initiates conversion.
INTR Goes to logic 0 when conversion is complete and remains low until another conversion is initiated.
i/p Analogue input signal applied here.
CS Enables the device, when logic 0.
D0 - D7 Tri-state digital outputs.
 
 

The Comparator and the DAC
 
Many lecturers like to get their students to develop their own ADC using a DAC and a comparator. To meet this need, the output of the DAC is also applied to the inverting pin of a comparator, as shown in the logic diagram extract below.
 
Logic diagram showing the comparator and DAC connections only (notice the ADC is disabled, therefore its connections to the 8051 are not shown).
 
 

The analogue input that is applied to the ADC is also applied to the non-inverting pin of the comparator, as can be seen above (in this extract, since the ADC is disabled, the analogue voltage connection to the ADC is omitted). If you look at the hardware image above you will see a button (above the ADC) with the title ADC Enabled. When this button is clicked the title changes to Comparator Enabled and the input voltage slider's title changes from ADC to Comparator, as shown opposite.

This corresponds to the switch at the ADC chip select and the switch between the comparator output and P3.7. By default, the ADC is enabled and the comparator output is isolated. In the logic diagram extract above you can see the switch between the comparator output and P3.7 is closed while at the same time the ADC CS line is switched to +V, disabling the ADC.

Comparator Panel
 
When the comparator is enabled it can then be used together with the DAC to implement an ADC. There are many techniques that can be used.
Learn about comparators and DACs used as ADCs (an external site that is not affiliated with EdSim51)
 
If we click the ADC Enabled button the ADC is disabled and the comparator's output is applied to P3.7. Programs can then be written that, using the DAC and comparator, implement ADCs.
 
 

The Motor
 
 
P3.0 and P3.1 are applied to a dual bridge driver, the outputs of which are applied to a bi-directional DC motor. The truth table for the bridge and its effect on the motor is:
 
A
B motor
0 0 stop
0 1 forward
1 0 reverse
1 1 stop
Logic diagram showing the motor and UART connections only.

 
 

In the image on the left, the motor's shaft is in the default position (pointing at 3 o'clock). Notice the sensor (depicted by a vertical line at the top of the motor) is black.

When the motor's shaft lines up with the sensor, the sensor changes from black to red, as shown in the image on the right.

Motor Panel
 
The motor sensor, which is applied to P3.5, goes low once every revolution (in the simulator, whenever the motor shaft lines up with the sensor, the sensor changes from black to red and P3.5 goes to logic 0). P3.5 is the external clock source for timer 1. Therefore, code can be written that, using timer 1, counts the motor's revolutions.
The speed of the motor can be varied manually (using the slider to the right of the motor - take a look at the hardware screenshots above). This will make the rev. counting programs more interesting.
 
Note: The motor control lines share the TXD and RXD lines for the 8051's internal serial port. As can be seen in the logic diagram extract above, these lines are also connected to the external UART. Therefore, when exercising the motor, garbage messages may appear in the UART's receiver window. The function of the external UART is explained below.
 
The motor can be disabled by clicking on the Motor Enabled button. Why would you want to disable the motor? See The UART below.
 
 

The UART
 
 

As stated above, the motor control lines share the same port pins as the 8051 serial port RXD and TXD. An external UART is connected to P3.0 and P3.1.

Data received from the 8051's serial port appears in the Rx window. The data in this window can be cleared at any time by clicking the Rx Reset button.

External UART Panel
 
Data can be transmitted to the 8051's serial port by typing text in the Tx window and clicking on the Tx Send button, which initiates transmission. When this button is clicked, the Tx window's background colour changes to grey, indicating the window is not editable. The title of the Tx Send button changes to Tx Reset. Clicking on the button at this point clears the Tx window. Its background colour changes back to white - the user can type more text and click Tx Send to restart transmission.
The data transmitted by the external UART is terminated with the \r character (the ASCII code for \r is 0DH). In other words, when the text abc is transmitted by the UART, the actual data sent is abc\r (or, in ASCII - 61H 62H 63H 0DH).
 
The UART's default Baud rate is 19,200. The user can select from a drop-down list of standard Baud rates (as can be seen below). Whenever the Baud rate is changed, the external UART's receiver and transmitter are reset.
  The Baud Rate Drop-down List -- one of four Baud rates can be selected.
 
The UART can be set to even parity, odd parity or no parity by clicking on the Parity button, cycling through the three options:
No Parity (the default), Odd Parity and Even Parity.
For more information on the 8051 serial port and on adding a parity bit, click Beginner's Guide to the 8051 - Serial Port.
 
When communicating with the UART, the pins P3.0 and P3.1 will therefore be changing value, which will have the side effect of turning the motor. To stop this, the user can click the Motor Enabled button which has the effect of disabling the motor (the button's title then changes to Motor Disabled and the motor can be re-enabled by clicking the button again).
 
 

The Keypad
 
 
Logic diagram showing the keypad connections only.    
 
The 4 X 3 keypad is interfaced in a standard format, as can be seen in the logic diagram extract above. All of port 0's pins, except pin 7, are used by the keypad.
 
External 1 Interrupt: The 3 columns are connected to the inputs of an AND gate, the output of which is connected to P3.3, the external 1 interrupt pin. The AND gate is disabled (by default) because this pin (P3.3) is also used by the display-select decoder (see Display above). To make use of the external 1 interrupt with the keypad, click on the AND Disabled button, therefore enabling the AND gate. But remember, you won't be able to multiplex the displays and use keypad interrupts at the same time. Instead you should use busy-waiting on the keypad.
 
Notes on interfacing to a keypad: Beginner's Guide to the 8051 - Peripheral Interfacing
 
Keypad Modes
Next to the keypad is a menu (see image above). This gives the user a choice of three settings for the type of keypad. By default the keypad mode is set to Standard. The other two types are Pulse and Radio.
  • Standard - in standard mode the keys are independent of each other. Any number of keys can be closed at the same time. A closed key is reopened simply by clicking on it again.
  • Pulse - in pulse mode a key is closed while the (left) mouse button is held down. Once the mouse button is released the key reopens.
  • Radio - in radio mode only one key at a time can be closed. For example, if key 5 is pressed (ie: closed) and then key 7 is pressed, key 5 automatically reopens. As in standard mode, a closed key is reopened simply by clicking on it again.
When the user switches to another keypad mode, using the adjacent menu, all closed keys are automatically reopened.
 
 

 
Saved Settings
The following settings are saved during the simulator shut down process:
 
  Original Setting
Update Freq. 1
Bitfield Address ACC
Data/Code Memory Data Memory
File System Directory Operating System Dependent
ADC/Comparator Enabled ADC Enabled
External UART Parity No Parity
External UART Baud Rate 19200 Baud
Keypad AND Gate Disabled
Keypad Type Standard
Motor Enabled/Disabled Enabled
LED Display/LCD Module LED Display Enabled
These settings are saved in a file called edsim51Settings.ser and the file itself is saved in the same folder (directory) as the edsim51.jar JAR file. When the simulator is launched it tries to open this file. If the file exists then the information in it is used to restore the system settings to the values they were at when the simulator was last shut down. If the file does not exist or is corrupted in some way, it is ignored and the simulator is launched with the original settings.
 
 

 
Note: When stepping through or running code, the length of time that passes is not only experienced by the 8051, but by all the peripherals as well.
If the instruction being executed is a 1 cycle instruction then, since the system clock is 12 MHz, the length of time passed is 1 us. Therefore, 1 us has passed for the UART and for the ADC and so on. In other words, if code is not being executed, time has stopped.
 
If you have questions about the EdSim51 simulator, please visit our Comments page.
 
 
Home About the
Simulator

User's
Guide

Installation
Instructions
Examples Contact
Us
The Fundamental
Simulations
Beginner's Guide
to the 8051
Site Map

 
Copyright (c) 2005-2007 NyCelt LLC