EE 308 - Homework 11
Due April 20, 1999

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

\epsfig{file=hw11_fig1.eps,width=6.5in}

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

(a)
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.
(b)
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.
(c)
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?

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

3.
The following will help you prepare for Lab 12.

(a)
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.

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

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



Bill Rison
1999-04-13