summaryrefslogtreecommitdiffstats
path: root/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe3.c
diff options
context:
space:
mode:
authorSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
committerSven Eisenhauer <sven@sven-eisenhauer.net>2023-11-10 15:11:48 +0100
commit33613a85afc4b1481367fbe92a17ee59c240250b (patch)
tree670b842326116b376b505ec2263878912fca97e2 /Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe3.c
downloadStudium-master.tar.gz
Studium-master.tar.bz2
add new repoHEADmaster
Diffstat (limited to 'Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe3.c')
-rw-r--r--Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe3.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe3.c b/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe3.c
new file mode 100644
index 0000000..21ed738
--- /dev/null
+++ b/Bachelor/Mikroprozessorsysteme2/mi2/Termin2/Loesung/Termin2Aufgabe3.c
@@ -0,0 +1,31 @@
+#include "defines.h"
+
+int main(void)
+{
+ *PMC_PCER = 0x4000; // Power Enable für Parallel I/O Controller B
+ *PIOB_PER = 0x318; // Pin 8,9,3,4: Enabled (Initialisiert) (Lämpchen1,2,Schalter1,2)
+ // *PIOB_PER = 0x100; *PIOB_PER = 0x200; *PIOB_PER = 0x8; *PIOB_PER = 0x10
+ *PIOB_OER = 0x300; // Pin 8,9: Pin als Ausgabe verwenden (Lampe 1,2)
+
+ // Schalter werden nicht auf Input geschaltete, da dies Default Zustand ist
+ // Lämpchen ist initialisiert und auf Output gesetzt.
+
+ int i;
+
+ while (1)
+ {
+ *PIOB_SODR = 0x100; // Pin 8: Lampe 1 an
+ for (i=0; i<125000; i++); // Pause
+ *PIOB_CODR = 0x100; // Pin 8: Lampe 1 aus
+ for (i=0; i<125000; i++); // Pause
+
+ // PDSR wird erst geprüft nachdem Lampe 1 aus ist
+
+ if (!(*PIOB_PDSR & 0X8))
+ *PIOB_SODR = 0x200; // Pin 8: Lampe 2 an
+ if (!(*PIOB_PDSR & 0x10))
+ *PIOB_CODR = 0x200; // Pin 8: Lampe 2 aus
+ }
+ return 0;
+}
+