Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;*********************************************************************
- ;* McMaster University *
- ;* 2DP4 Microcontrollers *
- ;* Lab Section 0X *
- ;* First Name Last Name MACID ####### *
- ;* First Name Last Name MACID ####### *
- ;*********************************************************************
- ;*********************************************************************
- ;* Title of your Code *
- ;* Brief Description of your Code *
- ;* *
- ;* *
- ;*********************************************************************
- ;*****************************************************************
- ;* This is code supplied to students for 2DP4 Lab #2 *
- ;* -T. Doyle *
- ;*****************************************************************
- ; 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 #%00000000
- BEQ X0
- CMPA #%00001000
- BEQ X1
- CMPA #%00001100
- BEQ X2
- CMPA #%00001110
- BEQ X3
- CMPA #%00001111
- BEQ X4
- X0 JMP XF
- X1 JMP XX
- X2 JMP XXX
- X3 JMP XXXX
- X4 JMP XXXXX
- ;The following segment is a 8 E cycle loop
- XF LDY #0 ; 10 * 0.5s * 0.5s
- LOOPON_OUT LDX #0 ; 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
- ;The following segment is a 8 E cycle loop
- LDY #10 ; 10 * 0.5s * 0.5s
- LOOPOFF_OUT LDX #40625 ; 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
- XX LDY #2.5 ; 20 * 0.5s * 0.5s
- LOOPON_OUT1 LDX #40625 ; 50.000us in 50ms (0.05s)
- LOOPON_IN1 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
- ;The following segment is a 8 E cycle loop
- LDY #7.5 ; 10 * 0.5s * 0.5s
- LOOPOFF_OUT1 LDX #40625 ; 50.000us in 50ms (0.05s)
- LOOPOFF_IN1 nop ; 1 E cycle
- nop
- nop
- nop
- nop
- dbne x,LOOPOFF_IN ; 3 E cycles
- dbne y,LOOPOFF_OUT ; 3 E cycles
- XXX LDY #5 ; 20 * 0.5s * 0.5s
- LOOPON_OUT2 LDX #40625 ; 50.000us in 50ms (0.05s)
- LOOPON_IN2 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
- ;The following segment is a 8 E cycle loop
- LDY #5 ; 10 * 0.5s * 0.5s
- LOOPOFF_OUT2 LDX #40625 ; 50.000us in 50ms (0.05s)
- LOOPOFF_IN2 nop ; 1 E cycle
- nop
- nop
- nop
- nop
- dbne x,LOOPOFF_IN ; 3 E cycles
- dbne y,LOOPOFF_OUT ; 3 E cycles
- XXXX LDY #7.5 ; 20 * 0.5s * 0.5s
- LOOPON_OUT3 LDX #40625 ; 50.000us in 50ms (0.05s)
- LOOPON_IN3 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
- ;The following segment is a 8 E cycle loop
- LDY #2.5 ; 10 * 0.5s * 0.5s
- LOOPOFF_OUT3 LDX #40625 ; 50.000us in 50ms (0.05s)
- LOOPOFF_IN3 nop ; 1 E cycle
- nop
- nop
- nop
- nop
- dbne x,LOOPOFF_IN ; 3 E cycles
- dbne y,LOOPOFF_OUT ; 3 E cycles
- XXXXX LDY #10 ; 20 * 0.5s * 0.5s
- LOOPON_OUT4 LDX #40625 ; 50.000us in 50ms (0.05s)
- LOOPON_IN4 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
- ;The following segment is a 8 E cycle loop
- LDY #0 ; 10 * 0.5s * 0.5s
- LOOPOFF_OUT4 LDX #0 ; 50.000us in 50ms (0.05s)
- LOOPOFF_IN4 nop ; 1 E cycle
- nop
- nop
- nop
- nop
- dbne x,LOOPOFF_IN ; 3 E cycles
- dbne y,LOOPOFF_OUT ; 3 E cycles
- BRA LOOP ; forever
- ;**************************************************************
- ;* Interrupt Vectors *
- ;**************************************************************
- ORG $FFFE
- DC.W Entry ; Reset Vector
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement