Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

asmIDE code 102% Tools Fill &Sign; Comment Shown below is a switch connected to

ID: 2293973 • Letter: A

Question

asmIDE code 102% Tools Fill &Sign; Comment Shown below is a switch connected to the IRQ or XIRQ pin of the HCS12 Write a program to get the status of the switch and increment a counting sequence on the 7-segment display each time the key is pressed. The switch should be connected to IRQ PEl or XIRQ PEOf the Trainer (Dragon12P), namely pin 55 (for Maskable Interrupt) or pin 56 (for Non- Maskable Interrupt) respectively You do not have to get any physical switch all you need is represent the closure of a switch by grounding the appropriate pin 4.7k HCS12 Switch ar XTR Procedure 1. Initialize and Program the appropriate Interrupt Registers appropriately 2. Design an appropriate ISR (Interrupt Service Routine) 3. Write down an Assembly code to create a dummy delay loop, and once the key has been the incremented sequence would appear on the on the 7-segment display and optionally on the L.EDs Notc 1. In Dragon12+ the RAM address is from S1000-3FFF 2. We use RAM addresses starting at $1000 for scratch pad (variables) and S3FFFfor stack. i pin The LEDs will not show the dala on Poet B unless you tarn off the PIJI bit. To do that, we must make P13 -output(DDRJ-OFF) and PIJ1-0Logic 0) See page 24 of the Dragonl2+ User's Manual 3. All bits of Port B are connected to LEDs. The LEDs are controlled by the PT3 ufsen Technology

Explanation / Answer


;Testing HCS12 MCU Module (from Freescale or Axiom) by Toggling PORTB in Assembly Language

;The HCS12 MCU Modules can be used with Freescale Student Project Board and they are made by Axiom.
;They can also be used as stand-alone without the Project Board. This Assembly tests the MCU Module without the Project Board
;The HCs12 MCU Modules are either C128 (HCSxxx128), DT256 (HCSxxx256), or XDT512 (HCSxxx512). See the designation on your Module.
;These HCS12 MCU Module comes with BDM and ready to work with CodeWarrior(only). Connect the module to the x86 PC USB port via a USB cable.
;The MCU module has 4-bit green LEDs and are located between Brown POT and Blue DIP SW.
;The LEDs are connected to PORTB7-PORTB4 via row of jumpers right in front of LEDs.
;Make sure the Jumpers are set for LEDs. They are designateed as LED1-LED4  
;Make sure the VB jumper for PWRr_SEL (next to power jack) is ALSO set. VB is the middle Jumper and allows the power come from USB cable (500 mA Maximum)
;WHEN USB CABLE IS THE EXCLEUSIVE PROVIDER OF POWER TO CPU MODULE, NEVER USE IT TO DRIVE POWER HUNGRY DEVICES SUCH AS DC OR STEPPER MOTORS
;In HCS12 MCU module RAM address is from $1000-3FFF
;We use RAM addresses starting at $1000 for scratch pad (variables) and $3FFF for Stack
;Modified from an example from Chapter 4 of HCS12 textbook by Mazidi & Causey
;Written and tested by Mazidi
  

;Make sure you are in TBDML Mode before downloading
;Press F7 (to Make), then F5(Debug) to downLOAD,and F5 once more to start the program execution

ABSENTRY Entry ; for absolute assembly: mark this as application entry point
  
; Include derivative-specific definitions
INCLUDE 'mc9s12dt256.inc' ;CPU used by DT256 Axiom MCU Module, Modify it for C128 or XDT512 Module


;----------------------USE $1000-$2FFF for Scratch Pad
R1 EQU $1001
R2 EQU $1002
R3 EQU $1003
;code section
ORG $4000 ;Flash ROM address
Entry:
LDS #$4000 ;Stack
LDAA #$F0
STAA DDRB ;PB7-PB4 output
  
;-------Toggling LEDs on PB7-PB4 of PORTB
BACK LDAA #%01010000
STAA PORTB ;Store A into PORTB
JSR DELAY
LDAA #%10100000
STAA PORTB
JSR DELAY
BRA BACK   
  
;----------DELAY
DELAY
PSHA ;Save Reg A on Stack
LDAA #10 ;Change this value to see  
STAA R3 ;how fast LEDs Toggle
;--10 msec delay. The Axiom board works with XTAL=4MHz
;Freq. for Instruction Clock Cycle is 2MHz (1/2 of 4MHz).
;(1/2MHz) x 10 Clk x 100 x 20 = 10 msec. Overheads are excluded in this calculation.
L3 LDAA #10
STAA R2
L2 LDAA #200
STAA R1
L1 NOP ;1 Intruction Clk Cycle
NOP ;1
NOP ;1
DEC R1 ;4
BNE L1 ;3
DEC R2 ;Total Instr.Clk=10
BNE L2
DEC R3
BNE L3
;--------------   
PULA ;Restore Reg A
RTS
;-------------------
  
;**************************************************************
;* Interrupt Vectors *
;**************************************************************
ORG $FFFE
DC.W Entry ;Reset Vector. CPU wakes here and it is sent to start of the code at $4000