EE 308 - Homework 11
Due April 20, 1999

A serial eight-channel 12-bit A/D converter communicates over the SPI with the following specifications:


The $\overline{\rm {CS}}$ line of the A/D converter is connected to the PP4 pin of the HC12.

Write some C code to set the the HC12 to communicate with the A/D converter. Be sure to make PP4 an output, deselct the A/D, set the SPI clock rate, clock polarity, and clock phase to work with the A/D. The SPI should be set up to use polling rather than interrupts.
Write some C code to tell the A/D to convert Channel 3. Read the value returned from Channel 3 and store it in a 16-bit number called channel_3.
The A/D converter has a range from 0 V to 5 V. The value returned from the A/D is 0x7A3. What analog voltage is on the Channel 3 input pin?

The following problem deals with the SPI flag.
How do you clear the SPI flag (SPIF bit of SP0SR register)?
Write some C code to clear the SPI flag.

The following will help you prepare for Lab 12.

Write some C code to set up the HC12 SPI to communicate with the MAX522 D/A converter chip. Again, be sure to set up the chip select line, the clock rate, the clock phase and the clock polarity. The SPI should work in polled rather than interrupt mode.

Write some C code to put 1.15 V on the OUTA pin of the MAX522.

Write some C code to put 3.57 V on the OUTB pin of the MAX522.

Bill Rison