EE 308 - LAB 12
Final version for 2001


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

For the prelab, write the program for Part 4 of this lab.

In this lab you will will use the HC12 SPI serial interface to communicate with a serial D/A converter. 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.

  1. Put the parts on your board for using a MAX522 D/A converter chip. This layout diagram shows one way to put the parts on your board. This schematic shows how to wire the project. In lab you will be given the tools and instructions on how to do this.

    When wire-wrapping, strip about 1" of insulation off the wire-wrap wire. (There is a wire stripper inside the wire wrap tool.) Put this into the smaller hole at the tip of the wire wrap tool. Put the bigger, central hole of the wire wrap tool over the pin you are wiring to. Turn the wire wrap tool -- either way will work; normally, a wire-wrap tool is turned clockwise to put a wire on. Be consistent -- if you make a mistake and need to remove a wire, you turn the tool the other way. Cut the wire so it is long enough to reach the other pin (with enough left over to strip 1" of insulation), but not much longer. Strip off 1" of insulation, and wrap onto the other pin.

    Here is the way I did it. Note that you should use green wire from ground pins, and red wire for power pins. The other colors are suggestions only; use any color (other than green and red) you like.

    1. Solder the parts on using a soldering iron at about 600 C. When soldering the items with more than two pins (the 8-pin socket and 4-pin header), solder two pins only. This will make it easier to remove if you make a mistake. Note that the 2.2 uF capacitor is polarized. The longer lead needs to be connected to +5V. Trim the capacitor leads so they are about the same length as the pins on the 8-pin socket.
    2. Put the Wrap-ID on the 8-pin socket. Make sure pin 1 is put in correctly.
    3. Connect grounds. Use green wire for grounds. First, connect the ground pins on C1 and C2 together. Connect from C1 ground to a GND (VSS) pin on the HC12. Connect from C2 ground to Pin 4 of the MAX522. Connect the two grounds (Pins 2 and 4) of the header. Connect from C3 ground to Pin 2 of the header. Connect from C4 ground to Pin 4 of the header. Connect from Pin 2 of the header to Pin 4 of the MAX522.
    4. Connect power. Use red wire for power. First, connect the power pins on C1 and C2 together. Connect from C1 power to a VDD pin on the HC12. Connect from C2 power to Pin 3 of the MAX522. Connect from Pin 3 to Pin 7 of the MAX522.
    5. Connect OUTA. Use white wire. Connect from the signal side of C4 to Pin 1 of the header. Connect from Pin 1 of the header to Pin 5 of the MAX522.
    6. Connect OUTB. Use white wire. Connect from the signal side of C3 to Pin 3 of the header. Connect from Pin 3 of the header to Pin 6 of the MAX522.
    7. Connect the SPI pins. Use blue wire. Connect from Pin 1 of the MAX522 to PS7 of the HC12. Connect from Pin 2 of the MAX522 to PS6 of the HC12. Connect from Pin 8 of the MAX522 to PS5 of the HC12.

  2. Use a voltmeter to verify continuity between the pins which are supposed to be connected. Before putting a MAX522 chip in, turn on power and verify that there are 5 volts at pins 3 and 7 of the eight-pin socket, and that pin 4 is connected to ground.

  3. 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.

  4. 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 control word to the D/A, read the status register, write the desired voltage value to the D/A converter (e.g, to tell it to generate an output voltage of 1.0 V on OUTA), read the status register, and deselect the D/A. Make sure both channels of the D/A work.

    Note that when you try to write to SPODR, DBug12 will tell you it couldn't do it -- that this address must be ROM. The reason for this is simple. Say you write an 0x22 to SP0DR. DBug12 writes an 0x22 to the register, then reads back to see if that value is there. When DBug12 reads SP0DR, it reads what was shifted in from the slave. Since nothing is connected to MISO, DBug12 will read an 0x00. This is not the same as what was written, so DBug12 thinks something is wrong. However, nothing went wrong, and the 0x22 was written to the MAX522 (if your wiring is correct).

  5. Connect a potentiometer to one of your A/D inputs, as you did in Lab 11. 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 15 times a second, using an RTI interrupt.

  6. Connect the SPI and slave select pins from your HC12 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 make sure these are the values you expected.



Bill Rison
2001-04-12