EE 308 - LAB 12
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 the on-board
A/D converter to read a voltage from a potentiometer, and reproduce that
voltage with the D/A converter. You will also send the voltage (as a
digital number) over the SPI to a neighbor's HC12. Your neighbor will
display the voltage on his/her LEDs and on the terminal.
- 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
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 a potentiometer to one of your A/D inputs, as you did in Lab 10.
Write a program to read the voltage from the A/D, 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 RTI interrupt.
- 4.
- Connect to a neighbor's HC12 using the SPI interface. Use pin
PP4 of the master HC12 as the slave select for the slave's SPI
-- i.e., connect PP4 of the master to SS of the slave.
Send the value of the potentiometer voltage to your neighbor over the SPI.
- 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.