logo

Crowdly

Browser

Add to Chrome

COMP317-Fall25-01-CE-EMBEDDED SYSTEMS

Looking for COMP317-Fall25-01-CE-EMBEDDED SYSTEMS test answers and solutions? Browse our comprehensive collection of verified answers for COMP317-Fall25-01-CE-EMBEDDED SYSTEMS at learn.hub.ku.edu.tr.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

Single_Button_Light_Move_Control:

Your second task is to modify your code for the first task to control four different move rates by a single button (PortB 0). Each “PortB 0” press should switch the light move rate to the next rate (in the order: turn-off, slow, faster, much faster, and then turn-off).

  • Button presses should not cause random jumps between rates.
  • BUTTON4 should still be functional to change the cycling pattern. 
  • Your program should ensure that the rate switch occurs only once per button press.
  • Single-button control functionality should work for any number of “PortB 0-3” buttons pressed for any reasonable duration.
  • Your grade will depend on the quality of your implementation!

Procedure:

  1. Create a new project named last-name_lab1_task2
  2. You can start with the ASM code for Task 1.
  3. Do your modifications on the source code. Assemble. Debug as necessary.
  4. Compute your coding resources, including program size in memory (in bytes), required data memory size (in bytes), and the number of registers in use. Please report them in the textbox below.
  5. Ensure you demo the functionality to the instructor.
  6. Submit your task2.asm code from the following file upload interface.

Important Hint: When you press a button, the mechanical contacts can undergo a transient state of short-duration connections and disconnections until they reach their final state. This is called “BOUNCING.” It is possible to eliminate bouncing with “DEBOUNCING” hardware; however, in this experiment, you are expected to implement “DEBOUNCING” in software.

View this question

Double_Click:

Repeat Task 2, but this time, the rate switch should occur after a “double-click” instead of a single one (as in double-clicking a mouse button, typically executed in 0.5 seconds.) As in Task 2, you need to implement debouncing in software.

  • The program should work for any number of “PortB 0-3” buttons double-clicked at any time.
  • BUTTON4 should still be functional to change the cycling pattern. 
  • Your grade will depend on the quality of your implementation!

Procedure:

  1. Create a new project named last-name_lab1_task3
  2. You can start with the ASM code for Task 2.
  3. Do your modifications on the source code. Assemble. Debug as necessary.
  4. Compute your coding resources, including program size in memory (in bytes), required data memory size (in bytes), and the number of registers in use. Please report them in the textbox below.
  5. Ensure you demo the functionality to the instructor.
  6. Submit your task3.asm code from the following file upload interface.
View this question

Write a lab report describing your design and implementation, and submit it as a file upload below. A lab report template is available online, which you can use as needed.

View this question

Light_Move_Control:

Your task is to create a moving light effect by controlling all LEDs and letting only two active (on) LEDs move one from left-to-right and one from right-to-left continuously (that is, the displayed bit patterns will cycle as $81, $42, $24, $18, $18, $24, $42, $81, $00,....). The speed of the moving-light effect will be controlled by pressing one of the buttons on Port B 0-4 with the following functionality.

  • BUTTON0: Turn off all the LEDs and stay in the off state until a new button is pressed.
  • BUTTON1: Moving light effect at a slow rate (~1 Hz for led-to-led move), and stays at the same move rate until a new button is pressed.
  • BUTTON2: Moving light effect at a faster rate (~3 Hz), and stays at the same move rate until a new button is pressed.
  • BUTTON3: Moving light effect at a much faster rate (~6 Hz), and stays at the same move rate until a new button is pressed.
  • BUTTON4: The moving-light effect splits the active LEDs with the cycling direction first from left-to-right, then from right-to-left ($80, $40, $20, $08, $04, $02, $01, $00, $01, $02, $04, $08, $10, $20, $40, $80, $00, ....) and preserves the previous move rate until a new button is pressed.

Procedure:

  1. Create a new project named last-name_lab1_task1
  2. You may copy and paste the content of the "lab0.asm".
  3. Do your modifications on the source code. Assemble. Debug as necessary.
  4. Compute your coding resources, including program size in memory (bytes), needed data memory size (bytes), and number of registers in use. Please report them in the text box below.
  5. Ensure you demo the functionality to the instructor.
  6. Submit your task1 .asm code from the following file upload interface.
View this question

Part 3: Getting familiar with the Easy AVR v7 development board and assembly programming

  1. Modify your “lab0.asm” code such that a key press to any bit bi turns off all even-indexed bits if index i is even, i.e., (b0, b2, ..., b6 ). Otherwise, if index i is odd, key press turns off all odd-indexed bits, i.e., (b1, b3, ..., b7 ). Don’t forget to save the modified code.
  2. Assemble (Build -> Build Solution)
  3. Go to “Start Menu” -> “All Programs” -> “Mikroelektronika” -> “AVRFLASH Programmer” -> “AVRFLASH”.
  4. In the “CODE” panel, press on the “Load” button and locate the binary file “\path-to-project-directory\Debug\lab0-lastname.hex”.
  5. Program the microcontroller by pressing the “Write” button.
  6. Make sure that the code functions as expected on the board. Report what you observe.
  7. Copy and paste your modified code into the following answer part.
  8. Demonstrate your code to the instructor/TA.
  9. Part 3 is all done. Thanks.
View this question

Part 2: Getting familiar with the Easy AVR v7 development board

Write your answers for each question below (specify the line numbers of each question) in the following answer part.

  1. Power the board with a USB cable (see page 7 of the User Guide).
  2. Turn Easy AVR v7 on, wait until the onboard LEDs are stable, and push the reset button.
  3. Push the reset button at the top right corner of the Easy AVR v7 board, and write down any observable changes on the development board.
  4. Go to “Start Menu” -> “All Programs” -> “Mikroelektronika” -> “AVRFLASH Programmer” -> “AVRFLASH”.
  5. In the popped-up window select the device model as “ATmega32”.
  6. Erase the code sector of the memory by pressing the “Erase” button.
  7. Repeat step 3.
  8. Start the “Atmel/Microchip Studio” program on your PC.
  9. Load your project from the preliminary work.
  10. Assemble (Build -> Build Solution)
  11. Go to “Start Menu” -> “All Programs” -> “Mikroelektronika” -> “AVRFLASH Programmer” -> “AVRFLASH”.
  12. In the “CODE” panel, press on the “Load” button and locate the binary file “\path-to-project-directory\Debug\lab0-lastname.hex”.
  13. Program the microcontroller by pressing the “Write” button.
  14. Make sure that the code works as expected on the board. Report what you observe.
  15. Turn Easy AVR v7’s power off. Disconnect the PC connection (from Easy AVR v7 side).
  16. Turn the power on again. Is your code still resident on the system?
  17. Go to your Lab0 directory, list the files, and check their content. What do you think these files are used for?
  18. Start the debugger by pressing the Start Debugging and Break (Alt + F5) button.
  19. Change the value of PIND, then check R16 and PORTB values as you debug a single step through the code. The PIND value can be changed in the "I/O" window. Are they consistent?
  20. Repeat steps 10-11-12-13-14 with the new value of PIND.
  21. Show and demo your code to the instructor/TA.
  22. Part 2 is all done. Thanks.
View this question

Part 1: Getting familiar with Atmel/Microchip Studio

Write your answers for each question below (specify the line numbers of each question) in the following answer part.

  1. Make sure that Atmel/Microchip Studio is installed on your computer.
  2. Start the “Atmel/Microchip Studio” program on your PC.
  3. Initiate a new project from File -> New -> Project, choose “Assembler” from “Installed”, browse your Lab0 drive location in “Location” at the bottom, and edit the name as “lab0-lastname”.
  4. Choose “ATmega32” as the device in the next window.
  5. Copy the content of the below “lab0.asm and paste it to your new “main.asm” window in Atmel Studio.
  6. Open the “Project” tab and choose “lab0-lastname Properties”. In the “Tool” tab, choose “Simulator” in the “Selected debugger/programmer” menu. Close the properties tab.
  7. Assemble (Build -> Build Solution)
  8. In the "Debug" tab, press the “Start Debugging and Break (Alt + F5)” and start pressing the F10 button to see the steps of the simulation. What do you observe? What is happening in the loop? Write down your observations in the answer part.
  9. Keep trying the "Run to Cursor" and "Reset" controls under the "Debug" tab. Write down your observations in the answer part.
  10. While debugging the code, observe register R16 in the "Processor Status" window, which should be on the right or can be accessed with the "Processor Status" icon on the menu above. What is happening to R16? Write down your observations in the answer part.
  11. There is a "Cycle Counter" field in the "Processor Status" window. Observe its characteristics as you run the code step-by-step in Debug mode, and write down your observations in the answer section.
  12. On the menu above find "Registers", "Memory", and "I/O" icons, and observe what they display. Write down your observations in the answer part.
  13. Show and demo your environment to the instructor/TA.
  14. Part 1 is all done. Thanks.

;*************************************************************************************

;*

;* File Name : "lab0.asm"

;* Title : ELEC/COMP 317 first program

;* Date : Februrary 19, 2021

;* Version : 1.0

;* Target MCU : ATmega32

;*

;* DESCRIPTION

;*

;* A simple program that turns off LEDs on the EasyAVR Development Kit

;* when the corresponding button is pressed.

;*

;*************************************************************************************

rjmp RESET ; Set up the reset vector.

; Other vector setup really should go here...

RESET:

ldi R16, $FF ; All ones makes

out DDRB, R16 ; port B all outputs

ldi R16, $00 ; All zeros makes

out DDRD, R16 ; port D an input

LOOP:

in R16, PIND ; Read buttons from port D

com R16 ; 1`s complement

out PORTB, R16 ; Output value of buttons to port B

rjmp loop ; Forever

View this question

Want instant access to all verified answers on learn.hub.ku.edu.tr?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome