Due April 9, 1998
- Write the master program to implement Lab 11. This program
needs to be typed. Be sure to do the following:
- Set up PIA Port A3--A0 as inputs, and PIA Port A4 as an output.
Program the PIA so an interrupt is generated on the falling edge of CA1.
- Set up the SPI to be a master, with speed, clock phase, and clock polarity
to match the MC68HC68T1 Real Time Clock (RTC).
- Set up the RTC to generate an interrupt once a second.
- Write an IRQ interrupt service routine which will be executed when
the button is pushed. In this ISR you should read PIA Port A, select the
slave, send the data
to SPI, wait until the data transfer is finished, and deselect the slave.
- Write an XIRQ interrupt service routine which will select
the RTC, read the current value of the time over the SPI, save the time
in a global array, set a global flag to show that a new time is available,
then deselect the RTC.
- In the main program loop you should monitor the global time flag, then
send the time to the PC screen using BUFFALO routines.
- Write the slave program to implement Lab 11. This program
needs to be typed. This will be identical to the program you wrote last week,
except the data transfer between the master and slave will be done over the
SPI rather than over the PIA parallel interface. Be sure to do the following:
- Set up the SPI as a slave, with clock phase and polarity matching the
master's, and with interrupts enabled when new data is available.
- Set up PIA Port B as an output, with no interrupt generated on CB1.
- Define four global variables each of which will hold the value for one of
the four patterns (in the case of the T-Bird, it will hold the index value of
the T-Bird table). Initialize these to 0.
- Define a global array for the T-Bird table. Declare the array to be on
type const, and initialize it when your define it.
- Define a global variable which will hold the pattern to implement on the
LEDs. Initialize this to 0.
- In your IRQ interrupt service routine, update the pattern global variable
(described above) to indicate which pattern to display. Also in this ISR,
change the update rate as told by the master.
- In your RTI interrupt service routine, look at the pattern global variable
to determine which pattern to display, and update the global variable for that
- Make sure you do not remain in either of the interrupt service routines
for very long. Neither of the routines should use while,
for or do loops.