Skip to content
Snippets Groups Projects
Commit 5ed42055 authored by Peter Gerwinski's avatar Peter Gerwinski
Browse files

Tafelbild und "Aufräumen" 27.11.2017

parent 3336c575
Branches
No related tags found
No related merge requests found
#include <stdio.h>
int main (void)
{
printf ("3 & 6 = %d\n", 3 & 6);
printf ("3 && 6 = %d\n", 3 && 6);
return 0;
}
......@@ -2,8 +2,8 @@
int main (void)
{
DDRD = 0x01; /* binär: 0000 0001 */
PORTD = 0x01; /* binär: 0000 0001 */
DDRD = 0x40; /* binär: 0100 0000 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
......@@ -2,7 +2,7 @@
int main (void)
{
DDRD = 0x01; /* binär: 0000 0001 */
DDRD = 0x40; /* binär: 0100 0000 */
PORTD = 0x00; /* binär: 0000 0000 */
while (1);
return 0;
......
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#define F_CPU 16000000l
#include <util/delay.h>
volatile uint8_t key_pressed = 0;
ISR (INT0_vect) /* PD2 */
{
key_pressed = 1;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1)
{
while (!key_pressed)
; /* just wait */
PORTD ^= 0x40;
key_pressed = 0;
}
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#define F_CPU 16000000l
#include <util/delay.h>
volatile uint8_t key_pressed = 0;
ISR (INT0_vect) /* PD2 */
{
key_pressed = 1;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1)
{
while (!key_pressed)
; /* just wait */
_delay_ms (1);
PORTD ^= 0x40;
key_pressed = 0;
}
return 0;
}
......@@ -5,12 +5,12 @@
int main (void)
{
DDRD = 0x01;
PORTD = 0x01;
DDRD = 0x02;
PORTD = 0x02;
while (1)
{
_delay_ms (500);
PORTD ^= 0x01;
PORTD ^= 0x02;
}
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
ISR (TIMER0_COMPB_vect)
{
PORTD ^= 0x40;
}
int main (void)
{
cli ();
TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */
TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */
sei ();
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
ISR (TIMER0_COMPB_vect)
{
PORTD ^= 0x40;
}
int main (void)
{
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
ISR (TIMER0_COMPB_vect)
{
PORTD ^= 0x40;
}
int main (void)
{
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x00; /* binär: 0000 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
ISR (TIMER0_COMPB_vect)
{
static uint8_t counter = 0;
if (counter++ == 0)
PORTD ^= 0x40;
}
int main (void)
{
cli ();
TCCR0B = (1 << CS01) | (1 << CS00); /* Takt durch 64 dividieren */
TIMSK0 = 1 << OCIE0B; /* Interrupt einschalten */
sei ();
DDRD = 0xfd; /* binär: 1111 1101 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
ISR (INT0_vect) /* PD2 */
{
PORTD ^= 0x40;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
ISR (INT0_vect) /* PD2 */
{
PORTD ^= 0x40;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xff; /* binär: 1111 1111 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1);
return 0;
}
#include <avr/io.h>
#include <avr/interrupt.h>
#include <stdint.h>
#define F_CPU 16000000l
#include <util/delay.h>
uint8_t key_pressed = 0;
ISR (INT0_vect) /* PD2 */
{
key_pressed = 1;
}
int main (void)
{
cli ();
EICRA = 1 << ISC00 | 1 << ISC01; /* INT0: steigende Flanke */
EIMSK = 1 << INT0; /* INT0 einschalten */
sei ();
DDRD = 0xfb; /* binär: 1111 1011 */
PORTD = 0x40; /* binär: 0100 0000 */
while (1)
{
while (!key_pressed)
; /* just wait */
PORTD ^= 0x40;
key_pressed = 0;
}
return 0;
}
No preview for this file type
......@@ -520,255 +520,4 @@
\end{frame}
\begin{frame}
\shownosectionnonumber
\begin{itemize}
\item[\textbf{1}] \textbf{Einführung}
\hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/hp.git}}}
\item[\textbf{2}] \textbf{Einführung in C}
\item[\textbf{3}] \textbf{Bibliotheken}
\item[\textbf{4}] \textbf{Hardwarenahe Programmierung}
\begin{itemize}
\color{medgreen}
\item[4.1] Bit-Operationen
\item[4.2] I/O-Ports
\item[4.3] Interrupts
\item[4.4] volatile-Variable
\color{red}
\item[4.5] Byte-Reihenfolge -- Endianness
\item[4.6] Speicherausrichtung -- Alignment
\end{itemize}
\item[\textbf{5}] \textbf{Algorithmen}
\begin{itemize}
\color{orange}
\item[5.1] Differentialgleichungen
\color{black}
\vspace*{-0.1cm}
\item[\dots]
\end{itemize}
\item[\textbf{\dots}]
\end{itemize}
\vspace*{-1cm}
\end{frame}
\subsection{Byte-Reihenfolge -- Endianness}
\subsubsection{Konzept}
\begin{frame}[fragile]
\showsubsection
\showsubsubsection
Eine Zahl geht über mehrere Speicherzellen.\\
Beispiel: 16-Bit-Zahl in 2 8-Bit-Speicherzellen
\smallskip
Welche Bits liegen wo?
\pause
\bigskip
$1027 = 1024 + 2 + 1 = 0000\,0100\,0000\,0011_2 = 0403_{16}$
\pause
\bigskip
Speicherzellen:
\medskip
\begin{tabular}{|c|c|l}\cline{1-2}
\raisebox{-0.25ex}{04} & \raisebox{-0.25ex}{03} & \strut Big-Endian "`großes Ende zuerst"' \\\cline{1-2}
\multicolumn{2}{c}{} & \pause für Menschen leichter lesbar \pause \\
\multicolumn{3}{c}{} \\[-5pt]\cline{1-2}
\raisebox{-0.25ex}{03} & \raisebox{-0.25ex}{04} & \strut Little-Endian "`kleines Ende zuerst"' \\\cline{1-2}
\multicolumn{2}{c}{} & \pause bei Additionen effizienter
\end{tabular}
\pause
\medskip
\textarrow\ Geschmackssache
\pause\\
\quad\textbf{\dots\ außer bei Datenaustausch!}
% \pause
% \bigskip
%
% Aber: nicht verwechseln! \qquad $0304_{16} = 772$
\end{frame}
\begin{frame}
\showsubsection
\showsubsubsection
Eine Zahl geht über mehrere Speicherzellen.\\
Beispiel: 16-Bit-Zahl in 2 8-Bit-Speicherzellen
\smallskip
Welche Bits liegen wo?
\medskip
\textarrow\ Geschmackssache\\
\textbf{\dots\ außer bei Datenaustausch!}
\begin{itemize}
\item
Dateiformate
\item
Datenübertragung
\end{itemize}
\end{frame}
\subsubsection{Dateiformate}
\begin{frame}
\showsubsection
\showsubsubsection
Audio-Formate: Reihenfolge der Bytes in 16- und 32-Bit-Zahlen
\begin{itemize}
\item
RIFF-WAVE-Dateien (\file{.wav}): Little-Endian
\item
Au-Dateien (\file{.au}): Big-Endian
\pause
\item
ältere AIFF-Dateien (\file{.aiff}): Big-Endian
\item
neuere AIFF-Dateien (\file{.aiff}): Little-Endian
\end{itemize}
\pause
\bigskip
Grafik-Formate: Reihenfolge der Bits in den Bytes
\begin{itemize}
\item
PBM-Dateien: Big-Endian\only<4->{, MSB first}
\item
XBM-Dateien: Little-Endian\only<4->{, LSB first}
\end{itemize}
\only<4->{MSB/LSB = most/least significant bit}
\end{frame}
\subsubsection{Datenübertragung}
\begin{frame}
\showsubsection
\showsubsubsection
\begin{itemize}
\item
RS-232 (serielle Schnittstelle): LSB first
\item
I$^2$C: MSB first
\item
USB: beides
\pause
\medskip
\item
Ethernet: LSB first
\item
TCP/IP (Internet): Big-Endian
\end{itemize}
\end{frame}
\nosectionnonumber{\inserttitle}
\begin{frame}
\shownosectionnonumber
\begin{itemize}
\item[\textbf{1}] \textbf{Einführung}
\hfill\makebox(0,0)[br]{\raisebox{2.25ex}{\url{https://gitlab.cvh-server.de/pgerwinski/hp.git}}}
\item[\textbf{2}] \textbf{Einführung in C}
\item[\textbf{3}] \textbf{Bibliotheken}
\item[\textbf{4}] \textbf{Hardwarenahe Programmierung}
\begin{itemize}
\color{medgreen}
\item[4.1] Bit-Operationen
\item[4.2] I/O-Ports
\item[4.3] Interrupts
\item[4.4] volatile-Variable
\item[4.5] Byte-Reihenfolge -- Endianness
\item[4.6] Speicherausrichtung -- Alignment
\end{itemize}
\item[\textbf{5}] \textbf{Algorithmen}
\begin{itemize}
\color{orange}
\item[5.1] Differentialgleichungen
\color{black}
\vspace*{-0.1cm}
\item[\dots]
\end{itemize}
\item[\textbf{\dots}]
\end{itemize}
\vspace*{-1cm}
\end{frame}
\iffalse
\setcounter{section}{4}
\section{Algorithmen}
\subsection{Differentialgleichungen}
\begin{frame}[fragile]
\showsection
\showsubsection
\vspace*{-2\bigskipamount}
\begin{picture}(0,0)
\put(8,-6.5){\includegraphics{pendulum.pdf}}
\end{picture}
\begin{eqnarray*}
\varphi'(t) &=& \omega(t) \\[\medskipamount]
\omega'(t) &=& -\frac{g}{l}\cdot\sin\varphi(t)\hspace*{7.1cm}
\end{eqnarray*}
\begin{itemize}
\item
Von Hand (analytisch):\\
Lösung raten (Ansatz), Parameter berechnen
\item
Mit Computer (numerisch):\\
Eulersches Polygonzugverfahren
\end{itemize}
\medskip
\begin{lstlisting}[gobble=0]
phi += dt * omega;
omega += - dt * g / l * sin (phi);
\end{lstlisting}
\bigskip
Praktikumsaufgabe: Basketball
\end{frame}
\begin{frame}
\showsubsection
\centerline{\makebox(0,0)[t]{\includegraphics[width=1.075\textwidth]{photo-20171106-170748.jpg}}}
\end{frame}
\fi
\end{document}
20171127/photo-20171127-170255.jpg

122 KiB

README: Bitweise und logische Und-Verknüpfung
echo avrdude -P /dev/ttyACM0 -c arduino -p m328p -U flash:w:$(ls -rt *.hex | tail -1)
avrdude -P /dev/ttyACM0 -c arduino -p m328p -U flash:w:$(ls -rt *.hex | tail -1)
avrdude -P /dev/ttyACM0 -c arduino -p m328p -U flash:w:$(ls -rt *.hex | tail -1) 2>/dev/null
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment