#include "inc/lm3s811.h" #include "jtag.h" //# include "inc/lm3s811.h" //#include "inc/hw_types.h" //#include "inc/hwmemmap.h" //#include "driverlib/sysctl.h" //#include "driverlib/gpio.h" int main(void) { /****** Bitte den folgenden Befehl nicht entfernen um sicherzustellen dass Ihr Board funktionstüchtig bleibt ******/ safe_startup(); /*******************************************************************************************************************/ SYSCTL_RCGC2_R |=4; //Schaltet Controllerperiferie; (s.28 Stellaris LM3S811) LED~PORTC C~ 2^0,1,(2)=4 GPIO_PORTC_DIR_R |=32; //Schaltet Portrichtung; 32 dez weil 2^(5)=32 (PC-5 Schaltbild) GPIO_PORTC_DEN_R |=32; // Schaltet als Digital Pin /*GPIO_PORTC_DATA_R |=32; */ GPIO_PORTC_DIR_R &= ~16; // Port 4 weil 16=2^4 GPIO_PORTC_DEN_R |= 16; // Idee: wenn Taste User (PC4) gedrückt ist => dann mit PWM-Steuerung: LED PC5 blinkt while(1) { if (GPIO_PORTC_DATA_R & 16) // Wenn Taste PC4 gedrückt ist { // GPIO_PORTC_DATA_R |= 32; //Dann LED PC5 an (Aus der anderen Aufgabe) // Configure the PWM generator for count down mode with immediate updates // to the parameters. PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); // Set the period. For a 50 KHz frequency, the period = 1/50,000, or 20 // microseconds. For a 20 MHz clock, this translates to 400 clock ticks. // Use this value to set the period. PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 400); // Configure the PWM generator for count down mode with immediate updates // to the parameters. PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); // Set the period. For a 50 KHz frequency, the period = 1/50,000, or 20 // microseconds. For a 20 MHz clock, this translates to 400 clock ticks. // Use this value to set the period. PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 400); // Set the pulse width of PWM0 for a 25% duty cycle. PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, 100); // Set the pulse width of PWM1 for a 75% duty cycle. PWMPulseWidthSet(PWM_BASE, PWM_OUT_1, 300); // Start the timers in generator 0. PWMGenEnable(PWM_BASE, PWM_GEN_0); // Enable the outputs. PWMOutputState(PWM_BASE, (PWM_OUT_0_BIT | PWM_OUT_1_BIT), true); } else { GPIO_PORTC_DATA_R &= ~32; //sonst LED PC5 aus } } } /* // Programm Muster für PWM // Configure the PWM generator for count down mode with immediate updates // to the parameters. // PWMGenConfigure(PWM_BASE, PWM_GEN_0, PWM_GEN_MODE_DOWN | PWM_GEN_MODE_NO_SYNC); // // Set the period. For a 50 KHz frequency, the period = 1/50,000, or 20 // microseconds. For a 20 MHz clock, this translates to 400 clock ticks. // Use this value to set the period. // PWMGenPeriodSet(PWM_BASE, PWM_GEN_0, 400); // // Set the pulse width of PWM0 for a 25% duty cycle. // PWMPulseWidthSet(PWM_BASE, PWM_OUT_0, 100); // // Set the pulse width of PWM1 for a 75% duty cycle. // PWMPulseWidthSet(PWM_BASE, PWM_OUT_1, 300); // // Start the timers in generator 0. // PWMGenEnable(PWM_BASE, PWM_GEN_0); // // Enable the outputs. // PWMOutputState(PWM_BASE, (PWM_OUT_0_BIT | PWM_OUT_1_BIT), true);