This is not a current assignment. If you are currently enrolled in CE2810, do not do this assignment expecting to receive credit for it.

Lab 4: Interrupts in C

Lab activity

Create a GCC project in AVR Studio and add all of the files from lab 3 except lab3.c. The lab3.c file should be replaced by a lab4.c file which you will implement.

Hardware Configuration

  • Connect the LEDs to PORTB.
  • Connect the LCD panel to PORTC.
  • Connect the keypad to PORTD.

Project Configuration

Be sure to configure your GCC project correctly. For example, make sure that you adjust the stack pointer location, specify that the C99 standard should be used, etc…

Program Functionality

The program should run continuously unless interrupted by either one of two push button events. One push button (referred to as Button Zero in this document) will trigger an external interrupt INT0. The other push button (referred to as Button One in this document) will trigger a different external interrupt INT1.

Each student may choose which buttons on the keypad are used for Button Zero and Button One. This choice should be clearly documented.

Implementation Details

The program should do the following:

  1. Initialize PORTB as an output port and turn LEDs off.
  2. Initialize the LCD panel on PORTC and display a “Welcome” message.
  3. Enable global interrupts as well as external interrupts INT0 and INT1.
    • INT0 must be configured to trigger on button-down and button-up events.
    • INT1 must be configured to trigger only on button-up events.
  4. Initialize a 16-bit unsigned integer as a counter with the initial value of 0.
  5. Following this initialization, the program should enter a loop that continuously increments the 16-bit counter value every 1 ms.
    • When the counter is incremented when containing the value 65535, it will “roll over” back to 0.
  6. Output only the high 8-bits of the 16-bit value to PORTB to light the LEDs.
  7. Recall that PD2 and PD3 of PORTD are internally connected to the interrupt subsystem of the ATmega32. Configure the keypad so that the desired (you choose) keys on the keypad will trigger INT0 and INT1.
    • When Button Zero is depressed, an ISR should be called that:
      1. Prevents further updates to the LEDs on PORTB until Button Zero is released. That is, the LEDs freeze until Button Zero is released, holding the immediate value of the counter at the time of the interrupt. For example, if the counter contained 0x3f02, then the LEDs should display the binary pattern corresponding to 0x3f. Note: the counter loop continues to run while Button Zero is depressed, so that when the button is released, the LEDs resume continuously display of the current value.
      2. Clears the LCD panel and displays the value of the counter on the LCD panel. For example, if the counter's value is 0x3f02, then the LCD should display the number 16130.
    • When Button One is triggered (by releasing the depressed button), the 16-bit counter value should be immediately reset to 0.

Demonstration

Each student must demonstrate the successful implementation of their program on their SunRom hardware. This demonstration is due by the end of the laboratory session.

FAST Data

You should indicate how much time (in minutes) you spend on this assignment in the FAST database. You are encouraged to log your activity as you work on the project. At a minimum, you should log all of the time spent on this assignment before the due date given above. All time spent on this assignment should be entered into the week 4 column (even if you worked on it in week 3 or 5).

Lab Deliverables

You should follow your instructor's instructions for your lab submission.

Hornick Taylor

If you have any questions, consult your instructor.

ce2810labs/lab4.txt · Last modified: 2010/03/09 20:55 (external edit)
 

This website is not owned or managed by the Milwaukee School of Engineering.

© 2003-2010 Dr. Christopher C. Taylor, et. al. • Office: L-343 • Phone: 277-7339 • npǝ˙ǝosɯ@ɹolʎɐʇ • -> RSS <-