·\'11 Verizon 1:02 PM njit2.mrooms.net ECET 311 - Embedded Systems Lab 4 Instruc
ID: 3348968 • Letter: #
Question
·'11 Verizon 1:02 PM njit2.mrooms.net ECET 311 - Embedded Systems Lab 4 Instruction Based Delay Routines Objectives 1. Students will learn how to program a simple instruction based delay sub-routine in AVR Assembly and will use the delay routine to control the blinking speed of LEDs. Students will load the final program on the development board to verify its functionality 2. Pre-Lab Write an assembly program that meets these requirements Starts the program code at address 0x0000. Initializes the Stack Pointer to the end of the AVR RAM Defines a main loop called "MAIN" that never exits and calls the following sub routines in the loop body: o Calls the subroutine named "LEDS ON o Calls the subroutine named "DELAY 500MS o Calls the subroutine named "LEDS OFF o Calls the subroutine named "DELAY 50OMS" . The code for LEDS ON and LEDS OFF is included in this lab DELAY 500MS should be an instruction based 450ms delay routine for an AVR running at 8 MHz written by you. DO NOT use routine provided for Labl Lab Exercise 1. 2. 3. Create an assembly project in Atmel Studio and enter your code into the project Build the project and make sure there are no errors Load the project on the EasyAVR v7 board a. In the programming window, make sure the AVR is set to use External Clock for Clock Source Verify that the PORTA LEDs flash on and then off every second b. Supplied Routin LEDS ON: SER R16 OUT DDRA, R16 OUT PORTA, R16 RET ; Set R16 to 0xFF Set all PORTA pins to output state Set al1 PORTA pins as logic high ;ReturnExplanation / Answer
ORG $0000 ; Initialization of adress code at 0x0000
LDI R16,LOW(RAMEND)
OUT SPL,R16
LDI R16,HIGH(RAMEND)
OUT SPH,R16
MAIN:
CALL LEDS_ON
CALL DELAY_500MS
CALL LEDS_OFF
CALL DELAY_500MS
RET
LEDS_ON:
; write the routine provided in que
RET
LEDS_OFF:
; write the routine provided in que
RET
DELAY_500MS:
LDI R18, 19
LDI R19, 68
LDI R20, 67
L1:
DEC R20
BRNE L1
DEC R19
BRNE L1
DEC R18
BRNE L1
RET
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.