ECE3120: Computer Systems Chapter 3 - PowerPoint PPT Presentation

1 / 40
About This Presentation
Title:

ECE3120: Computer Systems Chapter 3

Description:

The 68HC12 family is an upgrade of the popular 68HC11 8-bit microcontroller family. ... The assembly/disassembly process can be terminated by a period. ... – PowerPoint PPT presentation

Number of Views:129
Avg rating:3.0/5.0
Slides: 41
Provided by: gatew333
Category:

less

Transcript and Presenter's Notes

Title: ECE3120: Computer Systems Chapter 3


1
ECE3120 Computer SystemsChapter 3
  • Dr. Xubin He
  • http//iweb.tntech.edu/hexb
  • Email hexb_at_tntech.edu
  • Tel 931-3723462, Brown Hall 319

2
The HCS12 Members (1 of 2)
  • Is a redesign of the 68HC12 family
  • The 68HC12 family is an upgrade of the popular
    68HC11 8-bit microcontroller family.
  • The 68HC12 has a highest bus clock frequency of 8
    MHz.
  • The HCS12 family has a highest bus clock
    frequency of 32 MHz.
  • The numbering system is shown in Figure 3.1.

-
3
The HCS12 Members (2 of 2)
-
  • The HCS12 was initially designed for automotive
    and process control market.
  • The HCS12 has many features designed for these
    target markets
  • Parallel ports
  • Timer functions input capture, output compare,
    pulse accumulation, real-time interrupt, pulse
    width modulation, modulus down counter
  • Serial communication interface (SCI)
  • Serial peripheral interface (SPI)
  • Inter-integrated circuit (I2C)
  • Byte data link control (BDLC)
  • Controller Area Network (CAN)
  • Freescale also included the background debug mode
    (BDM) in each HCS12 member to facilitate the
    software debugging activities.
  • Freescale also include special features to target
    other applications
  • Ethernet controller the MC9S12NE64 has an
    Ethernet controller to facilitate the access of
    the Internet.
  • USB controller the MC9S12UF32 has an on-chip USB
    controller to facilitate the interfacing with USB
    bus.

4
Development Tools
  • Software development tools
  • Text editor, terminal program, cross assembler,
    cross compiler, simulator, source-level debugger,
    integrated development environment (IDE)
  • Hardware development tools
  • Oscilloscope, function generator, in-circuit
    emulator, logic analyzer, demo board
  • Only demo boards and BDM kit will be discussed.

5
Software Development Tools
  • A text editor allows the user to enter and edit
    the program.
  • A cross assembler allows the user to assemble
    their assembly programs.
  • A cross compiler allows the user to compile their
    programs written in high-level languages.
  • A simulator allows the user to run the
    application program without having the actual
    hardware.
  • A terminal program allows the PC to communicate
    with the hardware demo board.
  • A source-level debugger allows the user to set
    breakpoints in the program, trace program
    execution, watch program variable values after
    program execution, and so on.
  • An IDE combines all of the above programs in one
    package so the user can perform all software
    debugging activities in one environment without
    quitting any program.
  • The freeware miniIDE and asmIDE are recommended
    for assembly program development.
  • The freeware EmbeddedGNU IDE and GNU C compiler
    are recommended for C program development.

6
Demo Boards
  • Many HCS12-based demo boards are available for
    learning the HCS12 and debugging the HCS12
    application programs.
  • A demo board has an HCS12 MCU and many peripheral
    chips to help test the HCS12 programs.
  • A demo board often has an on-board monitor
    program to communicate with a PC or workstation
    on which the user develops the application
    program.
  • The monitor program allows the user to display
    register and memory location contents, setting
    register and memory location contents, setting
    program breakpoints, tracing instruction
    execution, and download programs onto the demo
    board for execution.
  • The PC or workstation communicates with the demo
    board using the terminal program.
  • The SSE256 from Shuan Shizu and the Dragon12 from
    Wytec are recommended for learning the HCS12
    microcontroller.

7
The Dragon12 Demo Board (1 of 2)
  • 24-MHz bus speed (generated from a 4-MHz crystal)
  • D-Bug12 monitor
  • 16 x 2 LCD kit (4-bit interface)
  • Eight LEDs
  • Four seven-segment displays
  • Keypad connector
  • Four buttons for input
  • DIP switches for input
  • Buzzer for playing siren and songs (wired to the
    PT5 pin)
  • Potentiometer for testing A/D function (wired to
    PAD7 pin)
  • Infrared transceiver
  • CAN transceiver (Philips PCA82C250)
  • A small breadboard
  • BDM IN and BDM OUT connectors
  • Two RS232 connectors
  • LTC1661 10-bit D/A converter chip with SPI
    interface
  • 24LC16 serial EEPROM with I2C interface
  • Additional information is available at
    www.evbplus.com

8
The Dragon12 Demo Board (2 of 2)
9
The D-Bug12 Monitor
  • Supports most HCS12 devices with 128KB and 256 KB
    flash memory
  • Used in many demo boards
  • Requires a host terminal program that supports
    the Xon/Xoff software handshake for proper
    operation
  • The HyperTerminal bundled with Windows and the
    terminal program bundled with asmIDE, miniIDE,
    and EmbeddedGNU IDE can work with D-Bug12
    monitor.
  • Supports four operating modes EVB mode, Jump to
    EEPROM mode, POD mode, and Serial Bootloader mode
  • After reset, the D-Bug12 reads the logic levels
    on the PAD1 and PAD0 pins to decide which of the
    four D-Bug12 modes to enter.

10
EVB Mode
-
  • The D-Bug12 monitor operates from the flash
    memory
  • The users are restricted to use SRAM (from 1000
    to 3BFF) or EEPROM to run application programs.
  • The user runs a terminal program on the PC to
    communicate with the D-Bug12 monitor on the demo
    board.
  • EVB operation model is shown below.

When the demo board is powered up and the baud
rate is set properly, the message as shown to the
right will appear on the terminal screen.
11
  • The D-Bug12 monitor displays the gt character
    to indicate it is ready for operation.
  • When a command issued to D-Bug12 is successfully
    executed, the monitor displays the execution
    result and a new gt character on a new line.
  • If a command is not successfully executed, press
    the reset button to get out.
  • An alternative to get out of the unsuccessful
    command is to press the abort key.
  • The abort key is connected to the XIRQ signal.
  • Dragon12 demo boards use the MC9S12DP256 as
    their MCU.
  • The memory maps for Dragon12 is shown below.

12
  • Using the D-Bug12 Commands
  • - BF ltStartAddressgt ltEndAddressgt ltDatagt
  • Fill a block of memory locations with the value
    of ltDatagt.
  • To fill the memory locations from 1000 to 1FFF
    with 0, enter the following command
  • gtbf 1000 1FFF 0
  • - MD ltStartAddressgt lt EndAddress gt
  • Display memory contents from lt StartAddress gt to
    lt EndAddress gt.
  • 16 bytes are displayed on each line.
  • The ltStartAddressgt is rounded down to the next
    lower multiple of 16.
  • The ltEndAddressgt is rounded up to the next
    higher multiple of 16.
  • Only one line is displayed if the EndAddress is
    not specified.

13
gtmd 1000 1000 AA 85 06 0C - D7 98 9A 61 - DF BE
BC E9 - 03 AE D0 3D .......a....... gtmd 1005
1020 1000 AA 85 06 0C - D7 98 9A 61 - DF BE BC
E9 - 03 AE D0 3D .......a....... 1010 75 DA
DF 39 - 3F 34 BD A9 - 2A CA FA DB - AC DA 18 97
u..9?4......... 1020 4D 5B 48 BA - B2 F7 B6 1B
- 92 99 E5 E4 - A5 E9 01 9F MH............. gt
MDW ltStartAddressgt ltEndAddressgt gtmdw
1000 1000 AA85 060C - D798 9A61 - DFBE BCE9 -
03AE D03D .......a....... gtmdw 1000
1020 1000 AA85 060C - D798 9A61 - DFBE BCE9 -
03AE D03D .......a....... 1010 75DA DF39 -
3F34 BDA9 - 2ACA FADB - ACDA 1897
u..9?4......... 1020 4D5B 48BA - B2F7 B61B -
9299 E5E4 - A5E9 019F MH............. gt
14
MM ltAddressgt ltDatagt
  • Used to examine and modify the contents of memory
    locations one byte at a time.
  • If the 8-bit data parameter is present on the
    command line, the byte at memory location
  • ltAddressgt is replaced with ltDatagt and the command
    is terminated.
  • If no data is provided, then D-Bug12 enters the
    interactive memory modify mode.
  • In the interactive mode, each byte is displayed
    on a separate line following the address of data.
  • Single-character sub-commands are used for the
    modification and verification of memory contents
    in interactive mode.
  • The available sub-commands are as follows
  • ltDatagt ltCRgt Optionally update current location
    and display the next location.
  • ltDatagt lt/gt or ltgt Optionally update current
    location and redisplay the same location.
  • ltDatagt ltgt or lt-gt Optionally update current
    location and display the previous location.
  • ltDatagt lt.gt Optionally update current location
    and exit Memory Modify.

15

gtmm 1000 1000 00 1001 00 FF 1002 00 1001 FF
1002 00 1003 00 55 / 1003 55 . gt MMW ltAddressgt
ltDatagt - Allows the contents of memory to be
examined and/or modified as 16-bit hex data. - If
the 16-bit data is present on the command line,
the word at memory location ltAddressgt is
replaced with ltDatagt and the command is
terminated. - If no data is provided, then
D-Bug12 enters the interactive memory modify
mode. - MMW supports the same set of
sub-commands as does the MM command.
16
gtmmw 1100 1100 00F0 1102 AA55 0008 1104 0000
1102 0008 aabb 1104 0000 1106 0000 . gt Move
ltStartAddressgt ltEndAddressgt ltDestAddressgt - The
number of bytes moved is one more than
ltEndAddressgt - ltStartAddressgt gtmove 1000 10ff
1100 gt RD register display gtrd PP PC SP
X Y D AB CCR SXHI NZVC 38 1521
3C00 2014 0000 6E14 1001
0100 xx1521 9C42 CPD 0042
gt
17
RM register modification gtrm PC0000
1500 SP0A00 IX0000 0100 IY0000 A00 B00
ff CCR90 d1 PC1500 . gt ltRegisterNamegt
ltRegisterValuegt - Allow one to change the value
of any CPU register. - Each bit of the CCR
register can be changed by specifying its name.
18
gtpc 2000 PC SP X Y D AB CCR
SXHI NZVC 2000 0A00 0100 0000 00FF
1101 0001 gtx 800 PC SP X Y D AB
CCR SXHI NZVC 2000 0A00 0800 0000 00FF
1101 0001 gtc 0 PC SP X Y D
AB CCR SXHI NZVC 2000 0A00 0800 0000
00FF 1101 0000 gtz 1 PC SP X Y
D AB CCR SXHI NZVC 2000 0A00 0800
0000 00FF 1101 0100 gtd 2010 PC SP
X Y D AB CCR SXHI NZVC 2000
0A00 0800 0000 2010 1101 0100 gt
19
ASM ltAddressgt (1 of 2)
  • Invokes the one-line assembler/disassembler.
  • Allows memory contents to be viewed and altered
    using assembly language mnemonics.
  • When displaying instructions, each instruction
    is displayed in its mnemonic form.
  • The assembly/disassembly process can be
    terminated by a period.
  • The one-line assembler displays the current
    instruction and allows the user to enter new
    instruction.
  • User can skip the current instruction by
    pressing the Enter key.

20
ASM ltAddressgt (2 of 2)
The following example displays instruction
starting from 2000 gtasm 2000 2000 FC0800
LDD 0800 gt 2003 CD0900
LDY 0900 gt 2006 CE000A
LDX 000A gt 2009 1810
IDIV gt 200B CB30
ADDB 30 gt 200D 6B44
STAB 4,Y gt 200F B7C5
XGDX gt 2011 CE000A
LDX 000A gt. gt The following
example enters three instructions (in bold face)
starting from 1500 gtasm 1500 1500 FC0800
LDD 0800 1503 F30802
ADDD 0802 1506 7C0900
STD 0900 1509 E78C
TST 12,SP gt. gt
21
BR ltAddressgt Setting or Examine Breakpoints
  • A breakpoint halts the program execution when the
    CPU reaches the breakpoint address.
  • When a breakpoint is encountered, the D-Bug12
    monitor displays the contents of CPU registers
    and the instruction at the breakpoint (not
    executed yet).
  • Breakpoints are set by typing the breakpoint
    command followed by one or more breakpoint
    addresses.
  • Entering the breakpoint command without any
    breakpoint addresses will display all the
    currently set breakpoints.
  • A maximum of ten user breakpoints may be set at
    one time.

gtbr 1020 1040 1050 set three
breakpoints Breakpoints 1020 1040 1050
gtbr display current breakpoints Breakpoints
1020 1040 1050 gt
22
NOBR ltAddressgt ltAddressgt
  • Delete one or more previously defined
    breakpoints.
  • All breakpoints will be deleted if no addresses
    are specified.

gtbr 2000 2010 2020 2040 2090 set four
breakpoints Breakpoints 2000 2010 2020 2040
2090 gtnobr 2000 2010 delete two
breakpoints Breakpoints 2020 2040 2090
gtnobr delete all breakpoints All
Breakpoints Removed gt
23
G ltAddressgt
  • Begin execution of user code at the specified
    address.
  • If no address is specified, CPU starts execution
    of the instruction at the current PC address.

gtg 1500 User Bkpt Encountered PP PC SP X
Y D AB CCR SXHI NZVC 38 150C 3C00
7B48 0000 03E8 1001 0001 xx150C
911E CMPA 001E gt
24
GT ltAddressgt
  • Execute instruction until the given address and
    stop.
  • User usually needs to specify where the program
    execution should start before issuing this
    command.

gtpc 1500 PP PC SP X Y D AB CCR
SXHI NZVC 38 1500 3C00 1000 1002 0000
1001 0101 xx1500 CF1500 LDS
1500 gtgt 1540 Temporary
Breakpoint Encountered PP PC SP X Y
D AB CCR SXHI NZVC 38 1510 1500 1000
1002 1E00 1001 0000 xx1510 3B
PSHD gt
25
T ltcountgt
  • Used to execute one or multiple instructions
    starting from the current PC address.
  • As each program instruction is executed, the CPU
    register contents and the next instruction to be
    executed are displayed.
  • Only one instruction will be executed when no
    count is specified.

gtpc 1500 PP PC SP X Y D AB CCR
SXHI NZVC 38 1500 1500 1000 1002 1E00
1001 0000 xx1500 CF1500 LDS
1500 gtt PP PC SP X Y
D AB CCR SXHI NZVC 38 1503 1500 1000
1002 1E00 1001 0000 xx1503 CE1000
LDX 1000 gtt 2 PP PC
SP X Y D AB CCR SXHI NZVC 38
1506 1500 1000 1002 1E00 1001
0000 xx1506 34 PSHX
PP PC SP X Y D AB CCR
SXHI NZVC 38 1507 14FE 1000 1002 1E00
1001 0000 xx1507 861E LDAA 1E
gt
26
CALL ltAddressgt
  • Used to execute a subroutine and returns to the
    D-Bug12 monitor program.
  • All CPU registers contain the values at the time
    the final RTS instruction was executed, with the
    exception of the program counter.
  • The program counter contains the starting address
    of the subroutine when returning from the
    subroutine.

gtcall 1600 Subroutine Call Returned pp PC SP
X Y D AB CCR SXHI NZVC 38 1600
0A00 0032 0900 0031 1001
0000 xx1600 FC1000 LDD 1000
gt
27
The Pod Mode
  • This mode is intended to run the demo board as a
    BDM host to control a target board.
  • Arrangement shown below

28
The Jump-to-EEPROM Mode
  • Execute a small program from the on-chip EEPROM
    whenever the EVB is powered up or reset.
  • This mode provides a way to execute a program in
    a standalone manner without having to erase and
    program the on-chip flash memory using the
    bootloader.

29
Tips for Assembly Program Debugging
  • Syntax errors
  • Misspelling of instruction mnemonics
  • Starting instruction mnemonic at column 1. The
    mnemonic is treated as a label whereas the
    operands are treated as mnemonic.
  • Missing operands
  • Will be highlighted by the assembler and are easy
    to fix.
  • Logic errors
  • Using extended (or direct) mode instead of
    immediate mode
  • A program with this type of addressing mode error
    is on the next page.


30
N equ 20 array count org 1000 array dc.b 2,4
,6,8,10,12,14,16,18,20 dc.b 22,24,26,28,30,32,34
,36,38,40 sum ds.w 1 org 1500 ldx array
place the starting address of array in
X movw 0,sum initialize sum to 0 ldy N
initialize loop count to N loop ldab 1,x place
one number in B and move array pointer sex B,D
sign-extend the 8-bit number to
16-bit addd sum add to sum std sum update
the sum dbne y,loop add all numbers to sum
yet? swi return to monitor end - Assemble
and download this program onto the demo
board. gtload .... done gt
31
  • Use the asm command to make sure that the
    program is downloaded correctly.
  • gtasm 1500
  • xx1500 FE1000 LDX 1000
    gt
  • xx1503 180400001014 MOVW 0000,1014
    gt
  • xx1509 DD14 LDY 0014
    gt
  • xx150B E630 LDAB 1,X
    gt
  • xx150D B714 SEX B,D
    gt
  • xx150F F31014 ADDD 1014
    gt
  • xx1512 7C1014 STD 1014
    gt
  • xx1515 0436F3 DBNE Y,150B
    gt
  • xx1518 3F SWI
    gt.
  • Make sure that program data is downloaded
    correctly. Use the md command
  • gtmd 1000 1010
  • 1000 02 04 06 08 - 0A 0C 0E 10 - 12 14 16 18 -
    1A 1C 1E 20 ...............
  • 1010 22 24 26 28 - 00 00 B9 A9 - 2A CA FA DB -
    AC DA 18 97 "(...........
  • gt

32
Run the Program
  • gtg 1500
  • User Bkpt Encountered
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1519 3C00 0213 0000 FF07 1001
    1000
  • xx1519 88F4 EORA F4
  • gt
  • Exam the execution result incorrect!!
  • gtmd 1010
  • 1010 22 24 26 28 - FF 07 B9 A9 - 2A CA FA DB -
    AC DA 18 97
  • gt
  • The program is short.
  • Errors can be found by tracing.
  • Set PC to the start of the program (at 1500)
  • gtpc 1500
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1500 3C00 0213 0000 FF07 1001
    1000
  • xx1500 FE1000 LDX 1000
  • gt

33
Trace One Instruction at a Time
  • gtt 1
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1503 3C00 0204 0000 FF07 1001
    0000
  • xx1503 180400001014 MOVW 0000,1014
  • gt
  • The executed instruction is ldx 1000 which
    should place the start address of the array in X.
  • The instruction trace result shows that X
    receives 0204, not 1000.
  • This is due to addressing mode error.
  • Change the instruction to ldx 1000 and rerun
    the program.
  • Reload the program and trace the program.
  • Trace two instructions this time.

34
  • gtt 2
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1503 3C00 1000 0000 FFF0 1001
    0000
  • xx1503 180400001014 MOVW 0000,1014
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1509 3C00 1000 0000 FFF0 1001
    0000
  • xx1509 DD14 LDY 0014
  • gtmd 1010 examine sum at 10141015.
  • 1010 22 24 26 28 - FF 00 B9 A9 - 2A CA FA DB -
    AC DA 18 97
  • gt
  • We expect the variable sum (at 1014 and 1015)
    to receive 0000. But it didnt.
  • The error is again caused by incorrect use of
    the addressing mode.
  • The movm 0,sum instruction copies the contents
    of memory location 0 to sum.
  • Change the second instruction to movw 0,sum.
    Rerun the program and examine the memory
    contents.
  • It is still incorrect !!

35
  • gtload
  • gtg 1500
  • User Bkpt Encountered
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1519 3C00 100F 0000 00F0 1001
    0000
  • xx1519 88F4 EORA F4
  • gtmd 1010
  • 1010 22 24 26 28 - 00 F0 B9 A9 - 2A CA FA DB -
    AC DA 18 97
  • gt
  • Trace the program up to the third instruction

36
  • gtpc 1500
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1500 3C00 100F 0000 00F0 1001
    0000
  • xx1500 CE1000 LDX 1000 1st
    instruction
  • gtt 3
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1503 3C00 1000 0000 00F0 1001
    0000
  • xx1503 180300001014 MOVW 0000,1014 2nd
    instruction
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1509 3C00 1000 0000 00F0 1001
    0000
  • xx1509 DD14 LDY 0014 3rd
    instruction
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 150B 3C00 1000 000F 00F0 1001
    0000
  • xx150B E630 LDAB 1,X
  • gt
  • The program intends to load 20 into Y with the
    third instruction and expect Y to be set to 20.
    But Y did not get 20. It receives 0F instead.
  • This is due to the incorrect use of the
    addressing mode.
  • Change the instruction to ldy 20 and rerun the
    program.

37
  • gtg 1500
  • User Bkpt Encountered
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 151A 3C00 1014 0000 01A4 1001
    0000
  • xx151A F421BD ANDB 21BD
  • gtmd 1010
  • 1010 22 24 26 28 - 01 A4 B9 A9 - 2A CA FA DB -
    AC DA 18 97
  • gt
  • After this correction, sum receives the correct
    value 1A4 (420).

38
Mismatch of Operand Size
  • Example Program Finding the sum of elements of
    an array
  • N equ 20 array count
  • org 1000
  • array dc.b 2,4,6,8,10,12,14,16,18,20
  • dc.b 22,24,26,28,30,32,34,36,38,40
  • sum ds.w 1
  • org 1500
  • ldx array place the starting address of array
    in X
  • movw 0,sum initialize sum to 0
  • ldy N initialize loop count to N
  • loop ldd 1,x place one number in D and move
    array pointer
  • addd sum add to sum
  • std sum update the sum
  • dbne y,loop add all numbers to sum yet?
  • swi return to monitor
  • end

39
  • The value of sum is incorrect after running the
    program
  • gtmd 1010
  • 1010 22 24 26 28 - A6 1F B9 A9 - 2A CA FA DB -
    AC DA 18 97
  • gt
  • This program can be debugged by tracing
  • gtpc 1500
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1500 3C00 1014 0000 A61F 1001
    1000
  • xx1500 CE1000 LDX 1000
  • gtt
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1503 3C00 1000 0000 A61F 1001
    0000
  • xx1503 180300001014 MOVW 0000,1014
  • gtt
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 1509 3C00 1000 0000 A61F 1001
    0000
  • xx1509 CD0014 LDY 0014

40
  • gtt
  • PP PC SP X Y D AB CCR SXHI
    NZVC
  • 38 150E 3C00 1001 0014 0204 1001
    0000
  • xx150E F31014 ADDD 1014
  • gt
  • The 4th instruction should place the value 2 in D
    rather than 0204. This is due to
  • the incorrect use of the instruction of ldd 1,x.
    This instruction should be replaced
  • by the following two instructions
  • ldab 1,x
  • clra
  • Other logic errors
  • Inappropriate Use of Index Addressing Mode
  • Indexed addressing mode is often used to step
    through array elements.
  • After accessing each element, the index register
    must be incremented or decremented.
  • Program execution cant be correct if index
    register is incremented or decremented
    incorrectly.
  • This error can be found after performing
    computation in the first one or two elements by
    program tracing.
Write a Comment
User Comments (0)
About PowerShow.com