summaryrefslogtreecommitdiffstats
path: root/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe2.c
diff options
context:
space:
mode:
Diffstat (limited to 'Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe2.c')
-rw-r--r--Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe2.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe2.c b/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe2.c
new file mode 100644
index 0000000..000f51a
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe2.c
@@ -0,0 +1,22 @@
+#include "defines.h"
+
+int main(void)
+{
+ *PMC_PCER = 0x4000; // Power Enable für Parallel I/O Controller B
+ *PIOB_PER = 0x118; // Pin 8: Enabled (Initialisiert) (Lämpchen)
+ // *PIOB_PER = 0x100; *PIOB_PER = 0x8; *PIOB_PER = 0x10
+ *PIOB_OER = 0x100; // Pin 8: Pin als Ausgabe verwenden
+
+ // Schalter werden nicht auf Input geschaltete, da dies Default Zustand ist
+ // Lämpchen ist initialisiert und auf Output gesetzt.
+
+ while (1)
+ {
+ if (!(*PIOB_PDSR & 0X8))
+ *PIOB_SODR = 0x100; // Pin 8: Lampe an
+ if (!(*PIOB_PDSR & 0x10))
+ *PIOB_CODR = 0x100; // Pin 8: Lampe aus
+ }
+ return 0;
+}
+