EE 308
Homework #4
Due Feb. 16, 1998

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

    Write a C 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 C program which increments Port B forever. Between each increment, use your "delay(n)" function to pause for 50 ms.

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

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

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

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

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

  7. Write a C program which counts the number of negative numbers from address range 0xE000 to <0xE0FF>. Treat the numbers in this region as signed one-byte numbers. Display the result on Port B.