Lab notes

This commit is contained in:
Jonathan Chan 2018-01-16 18:29:20 -08:00
parent e5f4f49928
commit 1e52725d6a
5 changed files with 162 additions and 46 deletions

View File

@ -1,6 +1,6 @@
\relax
\@writefile{toc}{\contentsline {section}{\numberline {1}Lab 1}{1}}
\@writefile{toc}{\contentsline {section}{\numberline {2}Lab 2}{1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Student Number}{1}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2}Program 1}{2}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.3}Program 2}{2}}
\@writefile{toc}{\contentsline {section}{\numberline {2}Lab 2}{3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.1}Student Number}{3}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.2}Program 1}{4}}
\@writefile{toc}{\contentsline {subsection}{\numberline {2.3}Program 2}{4}}

View File

@ -1,4 +1,4 @@
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6350 64-bit) (preloaded format=pdflatex 2018.1.7) 16 JAN 2018 17:01
This is pdfTeX, Version 3.14159265-2.6-1.40.18 (MiKTeX 2.9.6350 64-bit) (preloaded format=pdflatex 2018.1.7) 16 JAN 2018 18:28
entering extended mode
**"./Lab 1 and 2.tex"
("Lab 1 and 2.tex"
@ -79,46 +79,92 @@ LaTeX Font Info: External font `cmex10' loaded for size
(Font) <8> on input line 10.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <6> on input line 10.
LaTeX Font Info: Try loading font information for OMS+cmr on input line 17.
LaTeX Font Info: External font `cmex10' loaded for size
(Font) <10.95> on input line 29.
LaTeX Font Info: Try loading font information for OMS+cmr on input line 31.
("C:\Program Files\MiKTeX 2.9\tex\latex\base\omscmr.fd"
File: omscmr.fd 2014/09/29 v2.5h Standard LaTeX font definitions
)
LaTeX Font Info: Font shape `OMS/cmr/m/n' in size <10.95> not available
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 17.
(Font) Font shape `OMS/cmsy/m/n' tried instead on input line 31.
[1
{C:/ProgramData/MiKTeX/2.9/pdftex/config/pdftex.map}]
Overfull \hbox (53.37556pt too wide) in paragraph at lines 64--64
[] \OT1/cmtt/m/n/10.95 xor.b #0x41, R8 ; #00000001b -> #0100
0000b -> ... (LED0 -> LED1 -> ...)[]
Overfull \hbox (59.12425pt too wide) in paragraph at lines 79--79
[] \OT1/cmtt/m/n/10.95 |_____| | |_____| | |_____| |
|_____| | | set manually[]
[]
Overfull \hbox (53.37556pt too wide) in paragraph at lines 66--66
Overfull \hbox (59.12425pt too wide) in paragraph at lines 79--79
[] \OT1/cmtt/m/n/10.95 ______|SW| ______|SW| ______|SW|
______|SW| |__ w/ 5V|GND to[]
[]
Overfull \hbox (59.12425pt too wide) in paragraph at lines 79--79
[] \OT1/cmtt/m/n/10.95 | GRD_|__| | GRD_|__| | GRD_|__|
| GRD_|__| | O| select digit[]
[]
Overfull \hbox (18.88344pt too wide) in paragraph at lines 79--79
[] \OT1/cmtt/m/n/10.95 | | |
| |__| | |[]
[]
Overfull \hbox (18.88344pt too wide) in paragraph at lines 79--79
[] \OT1/cmtt/m/n/10.95 | | |
| | | |[]
[]
Overfull \hbox (24.63213pt too wide) in paragraph at lines 79--79
[] \OT1/cmtt/m/n/10.95 D3 D2 D1
D0 STR A1 A0[]
[]
Overfull \hbox (24.63213pt too wide) in paragraph at lines 79--79
[] \OT1/cmtt/m/n/10.95 11 10 01
00 == A1 A0[]
[]
[2] [3]
Overfull \hbox (53.37556pt too wide) in paragraph at lines 133--133
[] \OT1/cmtt/m/n/10.95 xor.b #0x41, R8 ; #00000001b -> #0100
0000b -> ... (LED1 -> LED2 -> ...)[]
[]
Overfull \hbox (53.37556pt too wide) in paragraph at lines 135--135
[] \OT1/cmtt/m/n/10.95 mov.w #40000, R10 ; counts to decrement
(2nd dec, since max val is 65536)[]
[]
[2] [3] ("Lab 1 and 2.aux") )
[4] [5] ("Lab 1 and 2.aux") )
Here is how much of TeX's memory you used:
1498 strings out of 493323
21395 string characters out of 3139061
80399 words of memory out of 3000000
5084 multiletter control sequences out of 15000+200000
8620 words of font info for 31 fonts, out of 3000000 for 9000
1500 strings out of 493323
21431 string characters out of 3139061
82399 words of memory out of 3000000
5086 multiletter control sequences out of 15000+200000
8979 words of font info for 32 fonts, out of 3000000 for 9000
1141 hyphenation exceptions out of 8191
26i,6n,32p,384b,251s stack positions out of 5000i,500n,10000p,200000b,50000s
26i,6n,32p,549b,219s stack positions out of 5000i,500n,10000p,200000b,50000s
<C:/Program Files/MiKTeX 2.9/fonts/type1/public/am
sfonts/cm/cmbx10.pfb><C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/c
m/cmbx12.pfb><C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr10.
pfb><C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr12.pfb><C:/P
rogram Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr17.pfb><C:/Program Fi
les/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Program Files/MiKT
eX 2.9/fonts/type1/public/amsfonts/cm/cmtt10.pfb>
Output written on "Lab 1 and 2.pdf" (3 pages, 96901 bytes).
m/cmbx12.pfb><C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi10
.pfb><C:/Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmmi8.pfb><C:/
Program Files/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr10.pfb><C:/Program F
iles/MiKTeX 2.9/fonts/type1/public/amsfonts/cm/cmr12.pfb><C:/Program Files/MiKT
eX 2.9/fonts/type1/public/amsfonts/cm/cmr17.pfb><C:/Program Files/MiKTeX 2.9/fo
nts/type1/public/amsfonts/cm/cmsy10.pfb><C:/Program Files/MiKTeX 2.9/fonts/type
1/public/amsfonts/cm/cmtt10.pfb>
Output written on "Lab 1 and 2.pdf" (5 pages, 117470 bytes).
PDF statistics:
40 PDF objects out of 1000 (max. 8388607)
54 PDF objects out of 1000 (max. 8388607)
0 named destinations out of 1000 (max. 500000)
1 words of extra memory for PDF output out of 10000 (max. 10000000)

Binary file not shown.

Binary file not shown.

View File

@ -10,11 +10,79 @@
\maketitle
\section{Lab 1}
The breadboard's wiring layout resembles this (there are two):
\begin{verbatim}
------------------ -------------------
------------------ -------------------
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
\section{Lab 2}
Some minor reminders:
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | | | | | | | | |
------------------ -------------------
------------------ -------------------
\end{verbatim}
In $V_{OH}, V_{IH}, V_{OL}, V_{IL}$,
\begin{itemize}
\item Remember to connect +5V and ground to 4-digit 7-segment display, and ground (\textbf{not} VCC) to microprocessor
\item The O/I means it's the voltage output/input
\item The H/L means it's a voltage HI/LO (or 1/0)
\end{itemize}
Max and min are the maximum and minimum acceptable voltage for that input/output for HI/LO.
For example, a gate's acceptable voltages may look like the following:
\newpage
\begin{verbatim}
+5V
||| max
|||
||| V_IH
|||
||| min
|
|
|
|
|
||| max
||| V_IL
||| min
=0V
\end{verbatim}
The 4-digit 7-segment multiplexed display has seven inputs:
\begin{itemize}
\item D3 D2 D1 D0: the input for a single digit, from \texttt{0x0} to \texttt{0xF}
\item A1 A0: the input for selecting a digit, where \texttt{0b11} is leftmost and \texttt{0b00} is rightmost
\item STR: when this voltage goes from LO to HI, the value given by Dx is loaded into the digit selected by Ax
\end{itemize}
Below is a rough circuit diagramme for wiring up the switches to the Dx inputs, the button to the strobe, and Ax:
\begin{verbatim}
Ohmm...
+5V ____VVV_____________________________________________________________
| __ | __ | __ | __ |
|_____| | |_____| | |_____| | |_____| | | set manually
______|SW| ______|SW| ______|SW| ______|SW| |__ w/ 5V|GND to
| GRD_|__| | GRD_|__| | GRD_|__| | GRD_|__| | O| select digit
| | | | |__| | |
| | | | | | |
D3 D2 D1 D0 STR A1 A0
_____________________________________________________
| __ __ __ __ |
| |__| |__| |__| |__| |
| |__| |__| |__| |__| |
|_____________________________________________________|
11 10 01 00 == A1 A0
\end{verbatim}
\newpage
\section{Lab 2}
Some minor reminders:
\begin{itemize}
\item Remember to connect +5V and ground to 4-digit 7-segment display, and ground (but \textbf{not} VCC) to microprocessor
\item \texttt{mspdebug} needs to be exited (with CTRL-D) for the program to run
\end{itemize}
\subsection{Student Number}
@ -49,8 +117,9 @@
dw START
\end{alltt}
\newpage
\subsection{Program 1}
Below is the full program annotated with comments. Making the lights blink twice as fast is simply halving the initial value set in R9, but making them blink twice as slow involves decrementing another register, since the doubled value is 80000 and will not fit in a two-byte word whose maximum value is 65536.
Below is the full program for half-speed blinking annotated with comments. Making the lights blink twice as fast is simply halving the initial value set in \texttt{R9}, but making them blink twice as slow involves decrementing another register, since the doubled value is 80000 and will not fit in a two-byte word whose maximum value is 65536.
\begin{alltt}
.include "msp430g2553.inc"
@ -61,7 +130,7 @@
mov.w #0x01, R8 ; #00000001b (start on LED1)
REPEAT:
mov.b R8, \&P1OUT
xor.b #0x41, R8 ; #00000001b -> #01000000b -> ... (LED0 -> LED1 -> ...)
xor.b #0x41, R8 ; #00000001b -> #01000000b -> ... (LED1 -> LED2 -> ...)
mov.w #40000, R9 ; counts to decrement before blink
mov.w #40000, R10 ; counts to decrement (2nd dec, since max val is 65536)
WAITER1:
@ -69,8 +138,8 @@
jnz WAITER1 ; R9 not yet 0
WAITER2:
dec R10
jnz waiter2 ; R10 not yet 0
jmp repeat ; R9, R10 == 0; blink other LED
jnz WAITER2 ; R10 not yet 0
jmp REPEAT ; R9, R10 == 0; blink other LED
org 0xfffe
dw START ; set reset vector to 'init' label
@ -78,16 +147,17 @@
\subsection{Program 2}
To make the LEDs cycle in the order
\\ \indent \texttt{none -> red -> green -> both -> none},\\
the output to P1OUT needs to be
\\ \indent \texttt{0000 0000 -> 0000 0001 -> 0100 0000 -> 0100 0001 -> 0000 0000}.\\
Notice that
\\ \indent \texttt{0000 0000 -> 0000 0001} \indent and \indent \texttt{0100 0000 -> 0100 0001}\\
can be done with an \texttt{xor} on \texttt{0000 0001}, and
\\ \indent \texttt{0000 0001 -> 0100 0000} \indent and \indent \texttt{0100 0001 -> 0000 0000}\\
can be done with an \texttt{xor} on \texttt{0100 0001}. Rather than using two registers to save the two different values to \texttt{xor} on, notice that in turn
\\ \indent \texttt{0000 0001 -> 0100 0001 -> 0000 0001}\\
can be done with an \texttt{xor} on \texttt{0100 0000}. Then we initialize a register (\texttt{R8} here) to \texttt{0000 0001}, and after we have \texttt{xor}ed it with the output, we \texttt{xor 0100 0000} on \texttt{R8} to get the next value that should be \texttt{xor}ed with the output. Below is the full program annotated with comments.
$$\indent \texttt{none -> red -> green -> both -> none},$$
the output to P1OUT needs to cycle through
$$\texttt{0000 0000 -> 0000 0001 -> 0100 0000 -> 0100 0001 -> 0000 0000}.$$
\newpage
Notice that the first and third transitions
$$\texttt{0000 0000 -> 0000 0001} \indent and \indent \texttt{0100 0000 -> 0100 0001}$$
can be done by applying \texttt{xor 0000 0001}, while the second and fourth transitions
$$\texttt{0000 0001 -> 0100 0000} \indent and \indent \texttt{0100 0001 -> 0000 0000}$$
can be done by applying \texttt{xor 0100 0001}. Rather than using two registers to save these two constants, notice that in turn
$$\texttt{0000 0001 -> 0100 0001 -> 0000 0001}$$
can be done by applying \texttt{xor 0100 0000}. Therefore we initialize a register, chosen here to be \texttt{R8}, to \texttt{0100~0001} (since the LEDs begin in the both-on state), and after we have applied \texttt{xor R8} on the output to obtain the next output, \texttt{0000~0000}, we apply \texttt{xor 0100~0000} on \texttt{R8} to get the next value of \texttt{R8}, \texttt{0000~0001}, that should be \texttt{xor}ed with the next output, and so forth. Below is the full program annotated with comments.
\begin{alltt}
#include "msp430g2553.inc"
@ -101,7 +171,7 @@
mov.b #00001000b, \&P1IE ; P1.3 set as an interrupt
mov.w #0x0049, R7 ; R7 = 0000 0000 0100 1001
mov.b R7, \&P1OUT ; LED1, LED2 on
mov.b #0x0041, R8 ; value to xor with R7
mov.b #0x0041, R8 ; value to xor with R7
EINT ; enable interrupts
bis.w #CPUOFF, SR
PUSH:
@ -112,7 +182,7 @@
reti ; return from interrupt
org 0xffe4
dw PUSH ; interrupt from button goes here
dw PUSH ; interrupt from P1.3 button goes here
org 0xfffe
dw RESET ; interrupt from reset button goes here