EE 308
Homework #5
Due Feb. 14, 1996

  1. The following function produces a 10 ms delay on the 68HC11:
      #define D_10MS 667
      void delay_10ms(void)
          int i;
          i = 0;
          while (i < D_10MS)
              i = i + 1;

    Write a function called "delay(n)" which will call "delay_10ms()" n times. For example, to create a 1 second delay, do the following:


  2. Write a program which increments Port B forever. Between each increment, use your "delay(n)" function to pause for 100 ms.

  3. Repeat Problem 2, but decrement Port B instead.

  4. Write a program which flashes between the binary patterns 0b01010101 and 0b10101010. Call your delay subroutine to delay for 100 ms between flashes.

  5. Write a program which implements a Thunderbird-style turn signal that alternates between left and right:

  6. Write a program which reads Port C, and uses bits 5 and 7 to control the function displayed on the LEDs. The following table shows what function to implement for different patterns of Port C:

    PC 7 PC 5 Port B Function
    0 0 Up Counter
    0 1 Down Counter
    1 0 Flasher
    1 1 Turn Signal