Docsity

Lab 5 Simple Interrupts - Computer Organization and Programming | ECE 375, Lab Reports of Electrical and Electronics Engineering

Partial preview of the text

Download Lab 5 Simple Interrupts - Computer Organization and Programming | ECE 375 and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

Lab 5

Simple Interrupts

Lab 6: Extremely Simple Computer (ESC)

Objectives

  • Understand how and when interrupts can be used
  • Demonstrate the use of simple interrupts
  • Explore how to configure interrupts on a microcontroller

Prelab

Be sure to have completed these prelab questions before your lab. They will help you to perform the tasks in this lab and hopefully give you more time to experiment.

  1. In computing there are traditionally two ways for a microprocessor to listen to other devices and communicate. These two methods are commonly called ‘polling’ and ‘interrupts.’ A large amount of information about these two methods exists. Please describe what each of them is and a few examples where you would choose one over the other.
  2. What is the function for each bit in the following registers in the ATMega128? EICRA, EICRB, and EIMSK. You can find this information from either the AVR Instruction Set guide, or the ATMega Reference Manual. You can find both of these on the TekBots webpage for the ECE375 course. HINT: These registers are related to ‘external interrupts.’
  3. The AVR microcontroller uses ‘interrupt vectors’ to run code when an interrupt is triggered. What is an interrupt vector? List the memory locations for the following vectors in the AVR microcontroller: Timer/Counter2 Comparison Match, External Interrupt 2, and USART1-Rx Complete.
  4. In the AVR microcontroller like with many others, there are several different ways of triggering interrupts. Below is a sample signal being input onto one of the external interrupt pins. List where the interrupt would trigger on this waveform if the interrupt was set up as: a.) rising edge, b.) Falling Edge, c.) Level High, and d.) Level Low.

Lab 6: Extremely Simple Computer (ESC)

option/solution. Your job as an engineer is to be able to choose the BEST option based on all pertinent information.

Write your assembly program and download it to your TekBot. Show your TA the operation and the code and have them sign below for credit. Be sure your code is well commented. Skeleton code is available on the webpage.

TA Signature: _________________________________________

Write Up

Write a short summary that details what you did and why, explain any problems you may have encountered, and answer the questions below. Submit your write up and code to your TA via email by the beginning of class the week following the lab. NO LATE WORK IS ACCEPTED.

Pseudo Code for Lab 5

  • Initialize Port(s)
  • Initialize Interrupt(s)
  • Loop Forever o Forward
  • Left Whisker Triggered (interrupt) o Reverse for 2 sec o Right for 500 ms o Return from Interrupt
  • Right Whisker Triggered (interrupt) o Reverse for 2 sec o Left for 500 ms o Return from Interrupt

Lab 5: Simple Interrupts

Additional Questions

  1. As an engineer you should be able to justify your design and testing choices. You have implemented this bumper TekBot in three ways now. Explain the benefits and costs of all three implementations. Some important areas of interest include, but are not limited to, efficiency, speed, cost of context switching, time to code, understandability, etc.
  2. Now that you have a basic understanding of interrupts would work, would it be possible to use a timer/counter interrupt to perform the wait loop while the robot is between transitions within the external interrupt? (HINT: The order in which the interrupt is located within the interrupt vector list is also the priority, the lower on the list, the higher the priority.) Give a reasonable argument either way.

Challenge

  1. Sometimes your TekBot can get caught in a loop where it is stuck in a corner and it continually backs up, hits the right whisker, then backs up and hits the left whisker, then the right, then left, and so on. Add a ‘memory’ to your TekBot so that it can detect this problem and when it has hit alternating whiskers five times, it will stop, turn around 180 degrees, and resume forward motion to get out of the corner. In addition, correct the simple problem of the TekBot hitting the same wall several times. In this scenario the TekBot hits one of its whiskers, backs up and turns away, but does not turn far enough and hits the same object. In this case you need to make the TekBot backup and turn away twice as far as if the whisker has been hit twice in a row. Write your program and keep it well documented. Turn in your code along with your write up and have you TA sign below that they have seen your functioning code.

TA Signature: ____________________