\documentclass[11pt]{article}
\usepackage{pdflscape}
\newif\ifpdf
\ifx\pdfoutput\undefined
    \pdffalse           % we are not running PDFLaTeX
\else
    \pdfoutput=1        % we are running PDFLaTeX
    \pdftrue
\fi
%----------------------------------------------------------------------
\ifpdf
    \usepackage[pdftex,
        letterpaper=true,
        colorlinks=true,
        urlcolor=rltblue,               % \href{...}{...}
        anchorcolor=rltbrightblue,
        filecolor=rltgreen,             % \href*{...}
        linkcolor=rltred,               % \ref{...} and \pageref{...}
        menucolor=webdarkblue,
        citecolor=webbrightgreen,
        pdftitle={EE 308 Spring 2010},
        pdfauthor={Bill Rison, New Mexico Tech},
        pagebackref,
        pdfpagemode=None,
        bookmarksopen=true]{hyperref}
    \pdfcompresslevel=9
    \usepackage[pdftex]{graphicx}
    \usepackage{thumbpdf}
\else
    \usepackage[dvips,
        letterpaper=true,
        colorlinks=true,
        urlcolor=rltblue,               % \href{...}{...}
        anchorcolor=rltbrightblue,
        filecolor=rltgreen,             % \href*{...}
        linkcolor=rltred,               % \ref{...} and \pageref{...}
        menucolor=webdarkblue,
        citecolor=webbrightgreen]{hyperref}
    \usepackage{graphicx}
\fi

\usepackage{color}
\definecolor{Red}{rgb}{1,0,0}
\definecolor{rltbrightred}{rgb}{1,0,0}
\definecolor{rltred}{rgb}{0.75,0,0}
\definecolor{rltdarkred}{rgb}{0.5,0,0}
%
\definecolor{rltbrightgreen}{rgb}{0,0.75,0}
\definecolor{rltgreen}{rgb}{0,0.5,0}
\definecolor{rltdarkgreen}{rgb}{0,0,0.25}
%
\definecolor{rltbrightblue}{rgb}{0,0,1}
\definecolor{rltblue}{rgb}{0,0,0.75}
\definecolor{rltdarkblue}{rgb}{0,0,0.5}

\definecolor{webred}{rgb}{0.5,.25,0}
\definecolor{webblue}{rgb}{0,0,0.75}
\definecolor{webgreen}{rgb}{0,0.5,0}


\usepackage{fancyhdr}
%\setlength{\parskip}{2ex}
%\setlength{\parindent}{2em}
\hoffset=-55pt
\voffset=-60pt
\textheight=9in
\textwidth=6.5in
\parindent=2em
\parskip=10pt
\pagestyle{fancy}
\lhead{\bfseries EE 308}
\chead{\bfseries }
\rhead{\bfseries Spring 2010}
\lfoot{\bfseries }
\cfoot{\thepage}
\rfoot{\bfseries }
\setlength{\headheight}{14pt}

\begin{document}
\parindent=0pt
\parskip=10pt

\begin{center} 
{\bf EE 308 -- Homework 7} \\[.1in]
Due Mar. 8, 2010\\
\end{center}
\begin{enumerate}

\item An engineer is using the MC9S12 to determine the speed of a motor in RPM.
A pulse is generated on Bit 1 of {\tt PORTT} 32 times every revolution of the
motor. Bit 1 of {\tt PORTT} is set up for input capture mode, and captures the
time of the rising edge. The prescaler bits PR2:0 are set to 011. It is known
that the time between pulses is less than the timer overflow time.  When the
first edge is captured, the TC1 register has a value of 0xC5A6.  When the
second rising edge is captured, the TC1 register has a value of 0x2794.

\begin{enumerate}
\item What it the length of time between the two rising edges?
\item How long does it take the motor to make one revolution?
\item What is the motor speed in RPM?
\end{enumerate}

\item What setup do you need to do to have the MC9S12 clear bit 4 of {\tt
PORTT} on a successful output compare?  Write some C code to do this.

\item What setup do you need to do to have the MC9S12 capture the time of a
falling edge on bit 0 of {\tt PORTT}?  Write some C code to do this.

\item Write some C code to set up the MC9S12 to capture the time of a falling
edge on Bit~0 of Port~T, and to generate an interrupt when the capture occurs.
Set the interrupt vector to point to the function \verb+tic0_isr+.  Set the
timer overflow interrupt rate to about 350~ms.  In the interrupt service
routine, set Bit 2 of Port E, and save the time of the edge in a global
variable.

\item Write some C code to set up the MC9S12 to capture the time of a falling
edge on Bit~1 of Port~T, and to generate an interrupt when the capture occurs.
Set the interrupt vector to point to the function \verb+tic1_isr+.  Set the
timer overflow interrupt rate to about 350~ms.  In the interrupt service
routine, clear Bit 2 of Port E, and save the time of the edge in a global
variable.

\item Write an interrupt service routine in C called \verb+toc4_isr+ which
generates a signal which looks like this on Pin 4 of Port T:


\end{enumerate}

\begin{center}
\includegraphics[width=5in]{friend}
\end{center}





\label{end}


\end{document}
