\documentclass[11pt,dvips]{article}
\usepackage{epsfig}
\usepackage{fancyheadings}
\setlength{\parskip}{2ex}
%\setlength{\parindent}{0em}
\hoffset=-55pt
\voffset=-60pt
\textheight=9in
\textwidth=6.5in
\parindent=0pt
\parskip=10pt
\pagestyle{fancy}
\lhead{\bfseries EE 308 }
\chead{\bfseries }
\rhead{\bfseries Spring 1999}
\lfoot{\bfseries }
\cfoot{\thepage}
\rfoot{\bfseries }
\setlength{\headrulewidth}{0.5pt}
\begin{document}

\begin{Large}

\begin{center}
{\bf HC12 - Two Choices of Clock for PWM}
\end{center}

\begin{enumerate}
\item PCLKx = 0:
\begin{itemize}
\item ${\rm Clk}_{\rm{x}} = 0.125 \mu{\rm{s}} \times 2^N$
\item ${\rm Per}_{\rm{x}} = 0.125 \mu{\rm{s}} \times 2^N \times ({\tt{PWPERx+1}})$
\end{itemize}
\item PCLKx = 1:
\begin{itemize}
\item ${\rm Clk}_{\rm{x}} = 0.125 \mu{\rm{s}} \times 2^{(N+1)} \times (M+1)$
\item ${\rm Per}_{\rm{x}} = 0.125 \mu{\rm{s}} \times 2^{(N+1)} \times (M+1) \times 
({\tt{PWPERx+1}})$
\end{itemize}
\end{enumerate}

$N$ = {\tt PCKA 2:0}  for PWM 1 and 0, $N = 0, 1, \cdots, 7$\\
$N$ = {\tt PCKB 2:0}  for PWM 3 and 2.\\[1ex]
$M$ = {\tt PWSCAL0 7:0} for PWM 1 and 0, $M = 0, 1, \cdots, 255$\\
$M$ = {\tt PWSCAL1 7:0} for PWM 3 and 2.\\[1ex]
Normally want {\tt PWPERx} = 200 $->$ 255.\\[1ex]
Example:  Want 5~kHz PWM -- Per$_{\rm{x}}$ = 200~$\mu$s.
\begin{enumerate}
\item  Try {\tt PCLKx} = 0 and {\tt PWPERx = 255}
$$200 \mu{\rm{s}} = 0.125 \mu{\rm{s}} \times 2^N \times ({\tt{PWPERx+1}})$$
$$2^N = \frac{200 \mu{\rm{s}}}{0.125 \mu{\rm{s}} \times 256} = 6.25$$
Not possible
Try {\tt PWPERx = 199}
$$2^N = \frac{200 \mu{\rm{s}}}{0.125 \mu{\rm{s}} \times 200} = 8$$
$$ N = 3$$
Exactly 5~kHz, get 1 part in 200 accuracy

\newpage

\item  Try {\tt PCLKx} = 1 and {\tt PWPERx = 255}
$$200 \mu{\rm{s}} = 0.125 \mu{\rm{s}} \times 2^{(N+1)} \times (M+1) \times ({\tt{PWPERx+1}})$$
$$2^{(N+1)} \times (M+1) = \frac{200 \mu{\rm{s}}}{0.125 \mu{\rm{s}} \times 256} = 6.25$$
Not possible.  Use a slightly different frequency -- let
$$2^{(N+1)} \times (M+1) =  6$$
$$N = 0 {\rm \ and \ } M = 2$$
This gives
$${\rm Per}_{\rm{x}} = 0.125 \mu{\rm{s}} \times 2^{(0+1)} \times (2+1) \times (255+1) = 192 \mu{\rm{s}}$$
for a 5.2~kHz frequency


\end{enumerate}

\end{Large}
\end{document}
