// Loesung zur Aufgabe Termin4 // Aufgabe 2 //**************************** // // // von: Manfred Pester // vom: 04. August 2020 #include "../h/pmc.h" #include "../h/pio.h" #include "../h/aic.h" #define Zaehlwert 100000 // Zaehlwert für warten void warten(unsigned load) { while((load--) > 0); return; } void Lauflicht(void) { int LED; StructPIO* piobaseB = PIOB_BASE; // Basisadress PIOB LED = (PIOB_BASE->PIO_PDSR & 0xff00) ^ 0xff00; // PDSR lesen und Bits der LED's maskieren PIOB_BASE->PIO_SODR = LED; // aktuelle LED's aus LED = LED << 1; // naechsten LED's if( LED & 0x10000 ) // wenn zu weit LED = (LED | LED1) & ALL_LEDS; // dann wieder erste LED PIOB_BASE->PIO_CODR = LED; // LED's einschalten } int main (void) { StructPIO* piobaseB = PIOB_BASE; // Basisadress PIOB StructPMC* pmcbase = PMC_BASE; // Basisadress PIOB pmcbase->PMC_PCER = 1 << PIOB_ID; // Peripheral Clock Enable for PIOB piobaseB->PIO_PER = ALL_LEDS; // Bit's fuer LED's aktivieren piobaseB->PIO_OER = ALL_LEDS; // Bit's fuer LED's sind Ausgaenge piobaseB->PIO_SODR = ALL_LEDS; // Bit's aller LED's auf logisch 1 (high) -> LED's aus piobaseB->PIO_CODR = LED1; // Bit fuer erste LED auf Logisch 0 (low) -> erste LED an while(1) { warten(Zaehlwert); Lauflicht(); } return (0); }