Difference between revisions of "U23 2007/Inhalt Abend 2/Schieberegister"
< U23 2007 | Inhalt Abend 2
m (Kategorie) |
|||
(9 intermediate revisions by 4 users not shown) | |||
Line 1: | Line 1: | ||
+ | ==Datenblatt== | ||
+ | * [http://www.it.lth.se/datablad/Logik/74HC/74HC4094.pdf 74HC4094 Schieberegister Datenblatt] | ||
+ | |||
+ | ==Bits Setzten== | ||
+ | |||
+ | Setze Bit an Stelle x | ||
+ | PORTA |= (1<<x); | ||
+ | |||
+ | lösche Bit an Stelle x | ||
+ | PORTA &= ~(1<<x); | ||
+ | |||
+ | [<< schifftet 1 um Anzahl von x Stellen! Achtung Anfang zu zählen bei 0] | ||
+ | |||
+ | ==Unsere Ansteuerung== | ||
+ | A0 - CP | ||
+ | A1 - Data | ||
+ | A2 - Strobe | ||
+ | A3 - OE | ||
+ | |||
+ | ==Programm== | ||
Schieberegister - Ansteuerung schiebe 1 0 rein und Ausgabe aktiv. | Schieberegister - Ansteuerung schiebe 1 0 rein und Ausgabe aktiv. | ||
#include <avr/io.h> | #include <avr/io.h> | ||
Line 5: | Line 25: | ||
#define STROBE 2 | #define STROBE 2 | ||
#define OE 3 | #define OE 3 | ||
+ | |||
int main(void) | int main(void) | ||
{ | { | ||
DDRA = 0xFF; | DDRA = 0xFF; | ||
PORTA = 0x00; | PORTA = 0x00; | ||
− | PORTA |= (1<<STROBE)|(1<<OE); | + | PORTA |= (1<<STROBE)|(1<<OE); //Setz Ausgänge auf aus! |
+ | |||
PORTA |= (1<<DATA); | PORTA |= (1<<DATA); | ||
PORTA |= (1<<CP); | PORTA |= (1<<CP); | ||
− | PORTA &= ~(1<<CP); | + | PORTA &= ~(1<<CP); //Wert 1 ins Register geschoben |
+ | |||
PORTA &= ~(1<<DATA); | PORTA &= ~(1<<DATA); | ||
PORTA |= (1<<CP); | PORTA |= (1<<CP); | ||
− | PORTA &= ~(1<<CP); | + | PORTA &= ~(1<<CP); //Wert 0 ins Register geschoben |
return 0; | return 0; | ||
} | } | ||
+ | |||
+ | |||
+ | Schieberegister - Ansteuerung | ||
+ | setzte 1 rein und Ausgabe an! | ||
+ | int main(void) | ||
+ | { | ||
+ | DDRA = 0xFF; | ||
+ | PORTA = 0x0E; | ||
+ | PORTA = 0x0F; | ||
+ | PORTA = 0x0E; | ||
+ | |||
+ | return 0; | ||
+ | } | ||
+ | |||
+ | [[Category:U23 2007]] |
Latest revision as of 13:37, 1 June 2007
Datenblatt
Bits Setzten
Setze Bit an Stelle x
PORTA |= (1<<x);
lösche Bit an Stelle x
PORTA &= ~(1<<x);
[<< schifftet 1 um Anzahl von x Stellen! Achtung Anfang zu zählen bei 0]
Unsere Ansteuerung
A0 - CP A1 - Data A2 - Strobe A3 - OE
Programm
Schieberegister - Ansteuerung schiebe 1 0 rein und Ausgabe aktiv.
#include <avr/io.h> #define CP 0 #define DATA 1 #define STROBE 2 #define OE 3 int main(void) { DDRA = 0xFF; PORTA = 0x00; PORTA |= (1<<STROBE)|(1<<OE); //Setz Ausgänge auf aus! PORTA |= (1<<DATA); PORTA |= (1<<CP); PORTA &= ~(1<<CP); //Wert 1 ins Register geschoben PORTA &= ~(1<<DATA); PORTA |= (1<<CP); PORTA &= ~(1<<CP); //Wert 0 ins Register geschoben return 0; }
Schieberegister - Ansteuerung
setzte 1 rein und Ausgabe an!
int main(void) { DDRA = 0xFF; PORTA = 0x0E; PORTA = 0x0F; PORTA = 0x0E; return 0; }