EE 308 - LAB 9

Serial Communications using the HC12 SPI and the MAX522 D/A Converter

In this lab you will will use the HC12 SPI serial interface to communicate with a serial D/A converter and with another HC12. You will use switches connected to Expanded Port B to tell what voltage to put out, and generate that voltage with the D/A converter. You will also send the value on the switches over the SPI to a neighbor's HC12. Your neighbor will display the value on his/her LEDs and on the terminal. Information about programming the MAX 522 can be obtained from the lecture notes, or from this datasheet.

1.
Make sure the wiring for the D/A part of your expansion is finished. Verify that there are 5 volts at pins 3 and 7 of the eight-pin socket, and that pin 4 is connected to ground. Get a MAX522 D/A chip, make sure power is turned off on your HC12 board, and plug the D/A converter into the eight-pin socket.

2.
Use DBug12 to verify that you can generate analog voltages from the D/A converter. You can set up the SPI by writing the appropriate values to the SPI control registers. Then select the D/A converter (by bringing the SS line low), write the value to the D/A converter to tell it to generate an output voltage (e.g., 1.0 V on OUTA), and deselect the D/A. Make sure both channels of the D/A work.

3.
Connect DIP switches to Expanded Port A. Write a program to read the switches, write the value to the D/A, and display it on the terminal. Do this at a rate of about 4 times a second, using an TOF interrupt.

4.
Connect to a neighbor's HC12 using the SPI interface. Send the value of the switches to your neighbor over the SPI. For this lab, remove the MAX 522 from the slave HC12 -- the HC12 can only control the MAX 522 when it is a master.

5.
Write a receiving program for the SPI. Set up the HC12 in slave mode, and enable the SPI interrupt. Whenever the master HC12 sends a value over the SPI, you should get an interrupt. Display the value on the LED's on your breadboard, and on your terminal.

6.
Connect the appropriate SPI and slave select pins to your logic analyzer, and capture a transfer over the SPI. Verify that the clock frequency, phase and polarity match the values you programmed them for. Decode the serial data stream for the transfer to the D/A converter and to the slave HC12, and make sure these are the values you expected.



Bill Rison
2000-04-07