CPR E 211: Introduction to Microcontrollers


Spring Semester, 2002
ASSIGNMENT #6
Due Date: Tuesday, April 30.


Note: This homework cannot be turned in for late credit. Its solutions will be published on Tuesday, April 30 at 5PM.

  1. Write an exception handler for MPC555 to reside at address 0x500 with the following behavior. It should check to see if the IRQ1 is the source of interrupt. Both a mouse and a keyboard are connected to IRQ1. They each have a control register with the least significant bit for ``READY'' and the next bit for ``Interrupt Enable''. Your interrupt handler should prioritize mouse over keyboard. [10 points]

  2. Write an exception handler for Vector #5 that does not use SIVEC based prioritization. It retains a history of servicing all of the possible 16 sources of interrupts in HISTORY[i]. When I0 (L0) is serviced, HISTORY[0] (HISTORY[1]) is turned on. The exception handler prioritizes (within software) by scanning all the sources of interrupt from left to right in the order I0, L0, I1, L1, I2, L2, ..., I7, L7. The first source that wants service and whose HISTORY[i] == 0 is serviced (and HISTORY[i] = 1). If a source i wants service, but HISTORY[i] = 1, then it is serviced only if no other source j with HISTORY[j] = 0 wants service. When all the sources have been serviced, HISTORY[i] = 0 for all i, then the history is cleared, HISTORY[i] = 0 for all i. Service a Level k (IRQk) source by calling Level-k-Handler (IRQ-k-Handler). [10 points]

  3. Program the MPC555 PIT to raise an exception every 10 milliseconds. The exception handler should be called using SIVEC based IRQ/jump table. Model your answer along the lines of Lecture 23. You can see an example of SIVEC based ISR call on Page 33 of the MPC555 interrupt handling document accessible from the class web page. The PIT interrupt handler should check to see if the time to the next interrupt is greater than 5 milliseconds, then it should reinitialize the PIT for an interrupt period of 50 milliseconds (otherwise leave it unchanged). [10 points]

  4. Program the TPU Channel 0 for input capture/input transition counter function as follows. It should count 100 rising transitions. The interrupt handler for this function should compute the average time between these transitions, AVG_TRANS_TIME. It should program the PIT to raise an interrupt at the period given by AVG_TRANS_TIME. The PIT interrupt handler checks to see if at least one transition was captured since the last PIT interrupt. If not, it reprograms the TPU Channel 0 to increment its MAX_COUNT (which is 100 initially) by one.

    [10 points]