Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The below code is given to make PortAD [PT1AD] a general I/O (digital) with b0-b3 as inputs and b4-b7 as outputs. Toggle switches are connected

The below code is given to make PortAD [PT1AD] a general I/O (digital) with b0-b3 as inputs and b4-b7 as outputs. Toggle switches are connected to the inputs. What is the name of the five registers used to control Port AD? What do each of them do?

; export symbols XDEF Entry, _Startup ; export 'Entry' symbol ABSENTRY Entry ; for absolute assembly: mark this as application entry point

; Include derivative-specific definitions INCLUDE 'derivative.inc'

ROMStart EQU $0400 ; absolute address to place my code/constant data

; variable/data section

ORG RAMStart ; Insert here your data definition.

; code section ORG ROMStart _Startup Entry ;================================================================ ; This portion of code signals to the programmer that the program ; has begun. ;================================================================ LDAA #$01 STAA DDRJ ; Configure PortJ's LSb as output STAA PTJ ; turn on uC LED (PJb0) to show "I'm alive!"

;================================================================ ; Configure PortAD [PT1AD] as gernal purpose I/O ; For ths lab, we will set inputs on b3-b0 and outputs b7-b4. ; Note the lab doesn't require output bits, but by moving your ; read-in bits to the output bits, it is an easy check to see if ; your code is receiving the expected data. ;================================================================ LDD #$000F STD ATDDIEN ;Configure PT1AD3-PT1AD0 as digital Input for toggle switches. (Default is analog for ADC) STAB PER1AD ;Enable internal pull up resistors to avoid indeterminate state when not connected LDAA #$F0 STAA DDR1AD ; set b7-b4 as digital output pins ; set b3-b0 as digital input pins

LOOP LDAA PTI1AD ; load A with toggle switch values (read from PortAD Input Buffer) LSLA ; move b3-b0 to b4-b1 LSLA ; move b4-b1 to b5-b2 LSLA ; move b5-b2 to b6-b3 LSLA ; move b6-b3 to b7-b4 STAA PT1AD ; save input switch values to output pins/LEDS

CMPA #$00 BEQ ALLOFF CMPA #$80 BEQ QUARTER CMPA #$C0 BEQ HALF CMPA #$E0 BEQ THREEQUARTER CMPA #$F0 BEQ ALLON ALLOFF LDAB #$00 STAB PTJ JMP LOOP ALLON LDAA #$01 STAA PTJ JMP LOOP ;================================================================ ;The following segment is a 8 E-cycle loop ;Assuming an E-clock f = 8MHz (T = 125ns), each iteration is 8*125ns = 1000ns = 1us ; QUARTER LDAA #$01 STAA PTJ LDY #10 ; 10 * .05s = 0.5s LOOPON_OUT LDX #19531 ; 50,000us in 50ms (0.05s) LOOPON_IN nop ; 1 E cycle nop nop nop nop dbne x,LOOPON_IN ; 3 E cycles dbne y,LOOPON_OUT ; 3 E cycles

;This segment will turn OFF the EsduinoXtreme's onboard LED LDAB #$00 STAB PTJ LDY #10 ; 10 * .05s = 0.5s LOOPOFF_OUT LDX #58593 ; 50,000us in 50ms (0.05s) LOOPOFF_IN nop ; 1 E cycle nop nop nop nop dbne x,LOOPOFF_IN ; 3 E cycles dbne y,LOOPOFF_OUT ; 3 E cycles JMP LOOP

;================================================================ ;The following segment is a 8 E-cycle loop ;Assuming an E-clock f = 8MHz (T = 125ns), each iteration is 8*125ns = 1000ns = 1us ; HALF LDAA #$01 STAA PTJ LDY #10 ; 10 * .05s = 0.5s LOOPON_OUT1 LDX #39062 ; 50,000us in 50ms (0.05s) LOOPON_IN1 nop ; 1 E cycle nop nop nop nop dbne x,LOOPON_IN1 ; 3 E cycles dbne y,LOOPON_OUT1 ; 3 E cycles

;This segment will turn OFF the EsduinoXtreme's onboard LED LDAB #$00 STAB PTJ LDY #10 ; 10 * .05s = 0.5s LOOPOFF_OUT1 LDX #39062 ; 50,000us in 50ms (0.05s) LOOPOFF_IN1 nop ; 1 E cycle nop nop nop nop dbne x,LOOPOFF_IN1 ; 3 E cycles dbne y,LOOPOFF_OUT1 ; 3 E cycles JMP LOOP

;================================================================ ;The following segment is a 8 E-cycle loop ;Assuming an E-clock f = 8MHz (T = 125ns), each iteration is 8*125ns = 1000ns = 1us ; THREEQUARTER LDAA #$01 STAA PTJ LDY #10 ; 10 * .05s = 0.5s LOOPON_OUT2 LDX #58593 ; 50,000us in 50ms (0.05s) LOOPON_IN2 nop ; 1 E cycle nop nop nop nop dbne x,LOOPON_IN2 ; 3 E cycles dbne y,LOOPON_OUT2 ; 3 E cycles

;This segment will turn OFF the EsduinoXtreme's onboard LED LDAB #$00 STAB PTJ LDY #10 ; 10 * .05s = 0.5s LOOPOFF_OUT2 LDX #19531 ; 50,000us in 50ms (0.05s) LOOPOFF_IN2 nop ; 1 E cycle nop nop nop nop dbne x,LOOPOFF_IN2 ; 3 E cycles dbne y,LOOPOFF_OUT2 ; 3 E cycles JMP LOOP

;================================================================

; BRA LOOP ; forever

;************************************************************** ;* Interrupt Vectors * ;************************************************************** ORG $FFFE DC.W Entry ; Reset Vector

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions