The Adapt-11 Board
The ADAPT11 (used with the Motorola 68HC11 Microcontroller) is a completely self contained evaluation board for the Motorola 68HC11 microcontroller. For information about the microcontroller refer to the various books by Motorola available in the RCA lab or refer to the book, "Microcomputer Engineering" by Gene H. Miller. The following is a step by step tutorial on the ADAPT11 board and some of the software available to use it (Note that the DOS commands given are only valid on the south side lab computers).
The Adapt-11 Board
The ADAPT11 board contains a 50 pin plug that can be inserted into a protoboard. On the top left side of the board there are two ports J1 which is the power supply port and J2 which is the RS-232 serial port. On the top right side of the board, there is a switch SW2 which can switch between run and boot mode. To the right of SW2 is a reset button SW1. On the right edge of the board is a jumper connector JP1 which when closed, connects the EEPROM chip to the 68HC11 chip. A layout of the board and the pin out can be seen in Figures 1 and 2.
Setting up the Board
To set up and program the 68HC11, the ADAPT11 board must first be connected to a personal computer and powered up.
Connect the white end of the black serial cable to the RS-232 serial port (J2) of the board. Connect the other end of the cable to the COM1 serial port of your computer (You may need to disconnect your computer's mouse).
To power up the system, connect the external power connector to J1 of the ADAPT11 board (the port next to the serial port). Power the system using a +9VDC power supply connected to the power connector (make sure that the polarity is correct).
In order to program the board, set the switch SW2 to the BOOT mode. To run a program set the switch to RUN mode.
Note that when the board in powered up, +5V can be taken from pin 47 and pins 49 and 50 will be ground.
Programming the 68HC11
In order to program the 68HC11, first set the switch SW2 to the BOOT mode.
On your PC, exit Windows or any other applications making sure that you are at the root directory:
C:\>
At the prompt, type the following to enter the 68HC11 source directory:
C:\>cd hc11src
In order to program the 68HC11 chip, programs can be written directly into the memory registers of the board or it can be stored into the external EEPROM chip. A memory map of the ADAPT11 board can be seen in Figure 3.
To program the memory registers, use the program PCBUG11. Make sure that the board is properly powered, connected to the computer and that the switch SW2 is set to BOOT. Press the reset button and then type:
C:\HC11SRC>pcbug11 -e
This will take you into PCBUG11. If any errors occur, exit PCBUG11 by typing quit. Check connections and type the above command again after pressing the reset button. You can also restart PCBUG11 by typing restart. Make sure to reset the board each time you start or restart the program.
PCBUG11 consists of four different windows colored black, blue, red and purple. The black window is the command window in which you control the PCBUG11 software. The blue window is where you interact with the 68HC11. The red window contains information about the 68HC11 such as accumulator values, pointer positions etc. The purple window contains information about the type of 68HC11 chip that you are using and various external connections. Using PCBUG11, you will be able to interact with the chip, modify memory and program the chip through the memory registers.
Before you can interact with the board to access the memory, you must set the value of the memory location $103C to $E5 (The '$' signifies that the number is in hexadecimal). To do this, type at the command prompt:
mm $103c $e5
This tells PCBUG11 to Modify Memory location $103c by changing its contents to $e5. Now you can program your chip and modify memory. Make sure that you do all programming and memory modifications in locations after $1FFF. Locations $0000 to $1FFF are reserved for PCBUG11's software communications, stack pointers, registers and port locations.
The following is a step by step approach to write and run a simple program to load a number to an accumulator, add a number to it and store the new number in a specific memory address. This is to familiarize you with some very basic commands of the PCBUG11 software.
At the command prompt, type:
asm $2000
This will open an assembler in the blue window at location $2000. You will see the memory address and other information similar to that given below:
2000 841F > ANDA #$1F
The number 2000 is the memory location label in hexadecimal. The number 841F is the contents of $2000 and $2001, where location $2000 contains the instruction $84 and $2001 contains the data $1F. ANDA is the instruction written in assembly corresponding to $84 and 1F is the data. The # symbol designates immediate addressing. The cursor will be at the space before the letter 'A' in the ANDA statement.
Replace the assembly instruction with the following, making sure that there is a space after the > sign:
LDAA #$20
This will load the number $20 into accumulator A. At the next line, type:
ADDA #$20
This will add the number $20 to the Accumulator A. Now type:
STAA $2020
This will store the new number in Accumulator A into location $2020. Press to return to the command window. Type:
dasm $2000 $2010
This will disassemble the code from $2000 to $2010 allowing you to reexamine your program. Then type:
rm
This will take you to the red window and allow you to modify the program counter (PC). Set the value to $2000 and then press. This will bring you back to the command window.
We will do a line by line execution of the program. In order to do this, type:
t
The letter t represents the word trace. This will execute the command at the location pointed by the PC. Now type:
rd
The command rd stands for display register. This will update and display the red window's contents. You will see that the PC's value is now $2002 and the ACCA (Accumulator A) is now $20. Now repeat the t and rd commands. The PC's value is now $2004 and ACCA is now $40.
The next command should store this new value, $40 into location $2020. First we will examine the contents of location of $2020. Type:
md $2020
This will display the contents of memory (memory display) in location $2020 as well as the contents of the next 15 memory locations, in the blue window. The contents of $2020 will be under the +0 title. Type the commands t and rd again. Now the contents of location $2020 must be reexamined. This time use the arrow keys to navigate through previous commands to find the previously typed command md $2020. The up arrow key will take you through previous commands and the down key will allow you to return. Press after you reach the command. You will see that $40 is now in the contents of $2020.
Next, we will write a similar program externally, assemble it and then load the assembled code into PCBUG11. First, exit PCBUG11 by typing quit followed by. Now, a text editor with a filename followed by the extension '.ASM' needs to be opened; in this example, we will call the file 'test.asm' and use the MS-DOS editor to write the program:
C:\HC11SRC>edit test.asm
This will open the editor allowing you to edit the file 'test.asm'. Now, type the following assembly program, making sure to use tabs as given:
mem_loc equ $2020 ; sets the variable 'mem_loc' to $2020
org $2000 ; write program from location $2000
ldaa #$10 ; load accumulator A with value $10
adda #$55 ; add $55 to the contents of A
staa mem_loc ; store value in A to location set by mem_loc
The first column of the program is used for variable name definitions or labels. The second column contains the opcodes or other assembly instructions. The third column contains the data and the fourth contains remarks which are preceded with a semi-colon.
Now press the keys and together. This will open the file menu. Using the arrow keys, select exit (or press ). The editor will ask you if you would like to save your program, select yes and the program will exit and return you to the HC11SRC prompt.
You now have your program written in assembly code. To assemble it, type the following:
C:\HC11SRC>as11 test.asm
This will assemble your code and place the created machine code into a file with the same file name but with extension '.s19'. Reenter PCBUG11 by typing the following after resetting the ADAPT11 board:
C:\HC11SRC>pcbug11 -e
Again, you must modify the memory in location $103c with $e5:
mm $103c $e5
Now to load your program, type:
loads test
Now disassemble the program to examine it:
dasm $2000 $2010
Modify the program counter (PC) to begin at location $2000:
rm
Set the value to $2000 and then press.
This time, instead of doing a line by line execution of the program, we will execute a block of code. In order to do this we will set a break point at location $2004, just before the 68HC11 executes the storage command. Type:
br $2004
A black window will appear in the top right corner of your screen showing the location of the break point. Press to exit the window and return to the command window.
To execute this block of program, type g for go:
g
The program will execute until it reaches the break point. Type rd to update the red window. The PC should now be $2004 and the value of ACCA will be $65. Now, examine the contents of location $2020:
md $2020
Type the commands t and rd again. Now the contents of location $2020 must be reexamined by typing md $2020 again or by using the arrow keys. The value of $65 should now be in the contents of $2020.
The previously inserted break can be removed by typing:
nobr
You should now have a basic understanding of PCBUG11. You can type help at any time in the command prompt to display the various commands available for the command window. PCBUG11 manuals are also available in the lab and can be borrowed by leaving your PENN ID with the lab administrators. Information on PCBUG11 is also available on the web site:
http://hydromail.supelec-rennes.fr/rennes/se/equipe/jweiss/68hc11/pcbug11/intro.htm
Reading and Writing With an External Circuit
The 68HC11 has several ports through which information can be read from an external circuit or written to a circuit. The ADAPT11 has external pins for you to access all the ports easily. However, in the ADAPT11, ports B and C of the microcontroller are disabled as the chip is in expanded mode. The designer of the board has routed the bidirectional ports A and B of the board's Xicor chip to the external pins of the board and renamed them ports B and C, respectively. These ports can be accessed, and can be found in locations $8400 to $87FF, along with several other important registers to control the Xicor chip. Refer to Figure 3 in this tutorial for information on the memory map of the board. Also, refer to the Xicor chip manual which can be obtained from the lab administrators for complete information.
The following is a simple circuit with a program in order to demonstrate and understand the external Xicor ports.
First, carefully place the board into a protoboard. From the board pin out in Figure 2, build the following circuit. From the port C pins, connect LEDs in series with low valued resistors (330) which are connected to +Vcc:
Place an eight count DIP switch on to the protoboard. At each switch, ground one end and connect the other end in series to a resistor (1k) which is connected to +Vcc. From the port B pins, tie the resistor/switch node to each pin. The schematic of the circuit is given below:
Connect pin 47 to the +Vcc strip of your board to produce the +5V. Make sure to ground pins 49 and 50. Now type in the following program. It will take in an input from the DIP switches through port B and output the value to the LEDs connected to port C. First the program must designate that port B should be an input port and port C an output port.
x_cr equ $8420 ; assigning a name to the Xicor control register
x_ppra equ $8430 ; assigning a name to the Xicor port A
x_pdrb equ $8408 ; assigning a name to the Xicor port B
org $2000
ldaa x_cr ; loading the current contents of x_cr in ACCA
anda #$FF ; Changing only the bits needed to modify ports
oraa #$04 ; A and B for input and output by masking.
staa x_cr ; placing the modified contents back in x_cr
loop: ldda x_ppra ; load the value set by the DIP switches into A
staa x_pdrb ; store the value from A into the LEDs
bra loop ; branch always to the label 'loop'
This program will continuously read in information from port B and output it to port C without stopping. Load the program using PCBUG11 and execute it using the go command g. You do not need to set a break point due to the infinite loop. Now change the values on your DIP switch. You will see that the LEDs will turn on and off accordingly.
For questions or comments on this tutorial or on the ADAPT11 board, contact Sevile George at sevile@seas.upenn.edu.Figure 3
The ADAPT11 (used with the Motorola 68HC11 Microcontroller) is a completely self contained evaluation board for the Motorola 68HC11 microcontroller. For information about the microcontroller refer to the various books by Motorola available in the RCA lab or refer to the book, "Microcomputer Engineering" by Gene H. Miller. The following is a step by step tutorial on the ADAPT11 board and some of the software available to use it (Note that the DOS commands given are only valid on the south side lab computers).
The Adapt-11 Board
The ADAPT11 board contains a 50 pin plug that can be inserted into a protoboard. On the top left side of the board there are two ports J1 which is the power supply port and J2 which is the RS-232 serial port. On the top right side of the board, there is a switch SW2 which can switch between run and boot mode. To the right of SW2 is a reset button SW1. On the right edge of the board is a jumper connector JP1 which when closed, connects the EEPROM chip to the 68HC11 chip. A layout of the board and the pin out can be seen in Figures 1 and 2.
Setting up the Board
To set up and program the 68HC11, the ADAPT11 board must first be connected to a personal computer and powered up.
Connect the white end of the black serial cable to the RS-232 serial port (J2) of the board. Connect the other end of the cable to the COM1 serial port of your computer (You may need to disconnect your computer's mouse).
To power up the system, connect the external power connector to J1 of the ADAPT11 board (the port next to the serial port). Power the system using a +9VDC power supply connected to the power connector (make sure that the polarity is correct).
In order to program the board, set the switch SW2 to the BOOT mode. To run a program set the switch to RUN mode.
Note that when the board in powered up, +5V can be taken from pin 47 and pins 49 and 50 will be ground.
Programming the 68HC11
In order to program the 68HC11, first set the switch SW2 to the BOOT mode.
On your PC, exit Windows or any other applications making sure that you are at the root directory:
C:\>
At the prompt, type the following to enter the 68HC11 source directory:
C:\>cd hc11src
In order to program the 68HC11 chip, programs can be written directly into the memory registers of the board or it can be stored into the external EEPROM chip. A memory map of the ADAPT11 board can be seen in Figure 3.
To program the memory registers, use the program PCBUG11. Make sure that the board is properly powered, connected to the computer and that the switch SW2 is set to BOOT. Press the reset button and then type:
C:\HC11SRC>pcbug11 -e
This will take you into PCBUG11. If any errors occur, exit PCBUG11 by typing quit. Check connections and type the above command again after pressing the reset button. You can also restart PCBUG11 by typing restart. Make sure to reset the board each time you start or restart the program.
PCBUG11 consists of four different windows colored black, blue, red and purple. The black window is the command window in which you control the PCBUG11 software. The blue window is where you interact with the 68HC11. The red window contains information about the 68HC11 such as accumulator values, pointer positions etc. The purple window contains information about the type of 68HC11 chip that you are using and various external connections. Using PCBUG11, you will be able to interact with the chip, modify memory and program the chip through the memory registers.
Before you can interact with the board to access the memory, you must set the value of the memory location $103C to $E5 (The '$' signifies that the number is in hexadecimal). To do this, type at the command prompt:
mm $103c $e5
This tells PCBUG11 to Modify Memory location $103c by changing its contents to $e5. Now you can program your chip and modify memory. Make sure that you do all programming and memory modifications in locations after $1FFF. Locations $0000 to $1FFF are reserved for PCBUG11's software communications, stack pointers, registers and port locations.
The following is a step by step approach to write and run a simple program to load a number to an accumulator, add a number to it and store the new number in a specific memory address. This is to familiarize you with some very basic commands of the PCBUG11 software.
At the command prompt, type:
asm $2000
This will open an assembler in the blue window at location $2000. You will see the memory address and other information similar to that given below:
2000 841F > ANDA #$1F
The number 2000 is the memory location label in hexadecimal. The number 841F is the contents of $2000 and $2001, where location $2000 contains the instruction $84 and $2001 contains the data $1F. ANDA is the instruction written in assembly corresponding to $84 and 1F is the data. The # symbol designates immediate addressing. The cursor will be at the space before the letter 'A' in the ANDA statement.
Replace the assembly instruction with the following, making sure that there is a space after the > sign:
LDAA #$20
This will load the number $20 into accumulator A. At the next line, type:
ADDA #$20
This will add the number $20 to the Accumulator A. Now type:
STAA $2020
This will store the new number in Accumulator A into location $2020. Press
dasm $2000 $2010
This will disassemble the code from $2000 to $2010 allowing you to reexamine your program. Then type:
rm
This will take you to the red window and allow you to modify the program counter (PC). Set the value to $2000 and then press
We will do a line by line execution of the program. In order to do this, type:
t
The letter t represents the word trace. This will execute the command at the location pointed by the PC. Now type:
rd
The command rd stands for display register. This will update and display the red window's contents. You will see that the PC's value is now $2002 and the ACCA (Accumulator A) is now $20. Now repeat the t and rd commands. The PC's value is now $2004 and ACCA is now $40.
The next command should store this new value, $40 into location $2020. First we will examine the contents of location of $2020. Type:
md $2020
This will display the contents of memory (memory display) in location $2020 as well as the contents of the next 15 memory locations, in the blue window. The contents of $2020 will be under the +0 title. Type the commands t and rd again. Now the contents of location $2020 must be reexamined. This time use the arrow keys to navigate through previous commands to find the previously typed command md $2020. The up arrow key will take you through previous commands and the down key will allow you to return. Press
Next, we will write a similar program externally, assemble it and then load the assembled code into PCBUG11. First, exit PCBUG11 by typing quit followed by
C:\HC11SRC>edit test.asm
This will open the editor allowing you to edit the file 'test.asm'. Now, type the following assembly program, making sure to use tabs as given:
mem_loc equ $2020 ; sets the variable 'mem_loc' to $2020
org $2000 ; write program from location $2000
ldaa #$10 ; load accumulator A with value $10
adda #$55 ; add $55 to the contents of A
staa mem_loc ; store value in A to location set by mem_loc
The first column of the program is used for variable name definitions or labels. The second column contains the opcodes or other assembly instructions. The third column contains the data and the fourth contains remarks which are preceded with a semi-colon.
Now press the keys
You now have your program written in assembly code. To assemble it, type the following:
C:\HC11SRC>as11 test.asm
This will assemble your code and place the created machine code into a file with the same file name but with extension '.s19'. Reenter PCBUG11 by typing the following after resetting the ADAPT11 board:
C:\HC11SRC>pcbug11 -e
Again, you must modify the memory in location $103c with $e5:
mm $103c $e5
Now to load your program, type:
loads test
Now disassemble the program to examine it:
dasm $2000 $2010
Modify the program counter (PC) to begin at location $2000:
rm
Set the value to $2000 and then press
This time, instead of doing a line by line execution of the program, we will execute a block of code. In order to do this we will set a break point at location $2004, just before the 68HC11 executes the storage command. Type:
br $2004
A black window will appear in the top right corner of your screen showing the location of the break point. Press
To execute this block of program, type g for go:
g
The program will execute until it reaches the break point. Type rd to update the red window. The PC should now be $2004 and the value of ACCA will be $65. Now, examine the contents of location $2020:
md $2020
Type the commands t and rd again. Now the contents of location $2020 must be reexamined by typing md $2020 again or by using the arrow keys. The value of $65 should now be in the contents of $2020.
The previously inserted break can be removed by typing:
nobr
You should now have a basic understanding of PCBUG11. You can type help at any time in the command prompt to display the various commands available for the command window. PCBUG11 manuals are also available in the lab and can be borrowed by leaving your PENN ID with the lab administrators. Information on PCBUG11 is also available on the web site:
http://hydromail.supelec-rennes.fr/rennes/se/equipe/jweiss/68hc11/pcbug11/intro.htm
Reading and Writing With an External Circuit
The 68HC11 has several ports through which information can be read from an external circuit or written to a circuit. The ADAPT11 has external pins for you to access all the ports easily. However, in the ADAPT11, ports B and C of the microcontroller are disabled as the chip is in expanded mode. The designer of the board has routed the bidirectional ports A and B of the board's Xicor chip to the external pins of the board and renamed them ports B and C, respectively. These ports can be accessed, and can be found in locations $8400 to $87FF, along with several other important registers to control the Xicor chip. Refer to Figure 3 in this tutorial for information on the memory map of the board. Also, refer to the Xicor chip manual which can be obtained from the lab administrators for complete information.
The following is a simple circuit with a program in order to demonstrate and understand the external Xicor ports.
First, carefully place the board into a protoboard. From the board pin out in Figure 2, build the following circuit. From the port C pins, connect LEDs in series with low valued resistors (330) which are connected to +Vcc:
Connect pin 47 to the +Vcc strip of your board to produce the +5V. Make sure to ground pins 49 and 50. Now type in the following program. It will take in an input from the DIP switches through port B and output the value to the LEDs connected to port C. First the program must designate that port B should be an input port and port C an output port.
x_cr equ $8420 ; assigning a name to the Xicor control register
x_ppra equ $8430 ; assigning a name to the Xicor port A
x_pdrb equ $8408 ; assigning a name to the Xicor port B
org $2000
ldaa x_cr ; loading the current contents of x_cr in ACCA
anda #$FF ; Changing only the bits needed to modify ports
oraa #$04 ; A and B for input and output by masking.
staa x_cr ; placing the modified contents back in x_cr
loop: ldda x_ppra ; load the value set by the DIP switches into A
staa x_pdrb ; store the value from A into the LEDs
bra loop ; branch always to the label 'loop'
This program will continuously read in information from port B and output it to port C without stopping. Load the program using PCBUG11 and execute it using the go command g. You do not need to set a break point due to the infinite loop. Now change the values on your DIP switch. You will see that the LEDs will turn on and off accordingly.
For questions or comments on this tutorial or on the ADAPT11 board, contact Sevile George at sevile@seas.upenn.edu.Figure 3
No comments:
Post a Comment