EE 308 Exam 2  Spring 1997

EE 308 - Exam 2

March 7, 1997

Name:

You may use any of the Motorola data books. No calculators allowed. Show all work. Partial credit will be given. No credit will be given if an answer appears with no supporting work.

1. Consider the timer subsystem of an HC11 with a 2 MHz E-clock.

(a) Without adjusting the prescaler, what is the longest time interval the HC11 can measure (without the timer wrapping around)?

(b) If you change the prescaler, what is the longest time interval the HC11 can measure (without the timer wrapping around)?

(c) What value does the prescaler have to have to measure this length of time? What special consideration do you need to observe when adjusting the prescaler?

(d) Write some C code which will set the prescaler to the value needed in the above part.

(e) Write some C code which will capture the time of a rising edge on Port A Bit 0, and generate an interrupt when this happens. This code should not affect any of the other timer subsystem functions.

(f) What physical pin on the HC11 (on your EVBU) does Port A Bit 0 correspond to?

(g) Write some C code to clear the Output Capture 3 flag. This code should not clear any of the other timer flags.

2. The following tables show the values of an HC11’s registers and some of its memory.

Reg     -        -

      S X H I N Z V C

CCR   1 0 0 0 0 1 0 1
A:B     A3       92
 X         82F2
 Y         12F7
SP         208D
PC         31F4
       0   1   2   3   4   5   6   7   8   9   A   B   C   D   E   F
2070  14  00  B7  23  B4  67  30  18  8F  FE  22  02  5C  E7  03  26
2080  0F  CC  A6  04  1B  9D  3F  12  20  EC  02  BD  00  1E  3C  96
2090  73  10  03  86  40  B7  10  25  3B  38  9A  05  F2  20  A5  ED
20A0  7A  10  04  86  80  B7  10  25  3B  38  9A  05  F2  20  A5  ED
FFD0  20  20  20  30  20  40  20  50  20  60  20  70  20  80  20  90
FFE0  21  A0  21  B0  30  D0  32  F0  21  00  21  10  21  20  21  30
FFF0  20  A0  21  50  21  60  21  70  21  80  21  90  21  A0  30  00
PACTL  TMSK1  TMSK2  TCTL1  TCTL2
 02     41     83     4E     1B

(a) What is the address of the first instruction the HC11 will execute after a reset?

(b) How often will the timer overflow?

(c) How often will the RTI flag be set?

(d) Which timer interrupts are enabled?

(e) What will happen to Port A Bit 6 when TCNT = TOC2?

(f) What will happen to Port A Bit 5 when TCNT = TOC3?

(g) What will happen to Port A Bit 4 when TCNT = TOC4?

(h) Will TIC1 capture the time of a changing edge on Port A Bit 2? If so, what edge?

(i) Will TIC2 capture the time of a changing edge on Port A Bit 1? If so, what edge?

(j) Will TIC3 capture the time of a changing edge on Port A Bit 0? If so, what edge?

(k) Write down the instructions in the RTI interrupt service routine.

(l) Write down the instructions in the TOI interrupt service routine.

(m) Assume the Real Time Interrupt Flag is set when the memory and registers are as shown above.. Show what will be in the HC11’s memory and registers when the HC11 gets to the first instruction in the interrupt service routine (before it actually executes that instruction). You only have to fill in blanks where registers or memory was changed.

 Reg    -        -            0  1  2  3  4  5  6  7  8  9  A  B  C  D  E  F
      S X H I N Z V C  2070
 CCR                    2080
 A:B                    2090
  X                     20A0
  Y                     FFD0
  SP                    FFE0
  PC                    FFF0

3. A 68HC11 is used to count the number of people entering a room. Every time some one enters the room, a pulse will be generated. You are asked to connect this pulse to one of your input capture pins. Write a program which will generate an interrupt when someone enters the room, and display the number of people in the room on LEDs connected to Port C. When the program is started the room is empty. (Don’t worry about decrementing Port C when someone leaves – maybe this is a prison, and when someone goes in, they can’t get out again).

(a) Which input capture pin are you going to use? What pin on the HC11 should you connect the pulse to?

(b) List at least six things you need to do in software to use interrupts on the HC11.

(c) Here is the start of your program. Finish writing the program. Be sure to include all the steps you listed above.

    #include <hc11.h>
    main()
    {
       while (1)
       {
       }
    }