Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************************************
- ;* Hochschule für Angewandte Wissenschaften Hamburg *
- ;* Fakultät DMI *
- ;* Department Medientechnik *
- ;* Veranstaltung: Informatik 3 & Elektronik *
- ;******************************************************************************
- ;* Praktikum Versuch2 *
- ;* Programmrumpf für C-Programme mit µVision4 von Keil *
- ;******************************************************************************
- ;*Namen / Matrikel-Nr.: 1. Till Grote 2079390 *
- ;* 2. Erik Münch 2315527 *
- ;* 3. Shiwam Arora 2270256 *
- ;******************************************************************************
- ;* Abgabedatum: 23.10.2017 *
- ;*****************************************************************************/
- #include <lpc11xx.h> // LPC1114 definitions
- int i = 0; //Timer
- unsigned int button1;
- int count = 0;
- int main(){
- LPC_SYSCON->SYSAHBCLKCTRL|=(1<<9); //mit Bitverschiebung auf 32Bit gestellt
- LPC_TMR32B0->PR = 12000; //Timer eingestellt/Prescaler auf 1 Takt pro ms
- LPC_GPIO2->DIR = 0xC0; // Output Pin2_6 und P2_7 definiert 1100 0000
- LPC_GPIO3->DIR = 0x3F; // Output Pin3_0 und P3_5 definiert 0011 1111
- LPC_TMR32B0->TCR = 0x2; //Timer reset und anhalten, TimeControlReg
- LPC_TMR32B0->MR3=1; //Match Reg 3 = 1
- LPC_TMR32B0->MCR=0x600; // Match Control Reg wenn sich MCR meldet soll Interrupt und Timerreset, 600 war im reg3
- LPC_TMR32B0->TCR = 0x1; //Timer starten
- NVIC->ISER[0]|= 0x40000; //Verbindet Interrupt mit der Exception auf bit 19 - 0100 0000 0000 0000
- while(1){ ; }
- }
- void TIMER32_0_IRQHandler(void){
- button1 = LPC_GPIO2->DATA; //Daten vom GPIO2 auslesen
- button1 = (button1 & 0x200)>>9; //0x200 >>9 = 1
- if(!button1){//wenn button gedrückt
- if(count<30){ //wird bis 30 hochgezählt
- count++;
- }}
- else{
- count=0;//button nicht gedrückt: counter auf 0
- }
- if(count>=30){ //wenn der counter groeßer als 30
- i++;// wird eine LED weitergeschaltet
- count=-500;//und der Counter auf negativ gesetzt um wiederholtes weiterschalten zu vermeiden.
- }
- if(i == 1){
- LPC_GPIO3->DATA= 0x3E; //3 LED1
- LPC_GPIO2->DATA= 0xFF; //2 alle aus
- }
- if(i == 2){
- LPC_GPIO3->DATA= 0x3D; //3 LED2
- }
- if(i == 3)
- {LPC_GPIO3->DATA= 0x3B;} //3 LED3
- if(i == 4)
- {LPC_GPIO3->DATA = 0x37; }//3 LED4
- if(i == 5){LPC_GPIO3->DATA = 0x2F;} //3 LED5
- if(i == 6) {
- LPC_GPIO3->DATA = 0x1F; //3 LED6
- }
- if(i == 7){
- LPC_GPIO2->DATA = 0xFBF;//2 LED7
- LPC_GPIO3->DATA = 0xFF;//3 alle aus
- }
- if(i == 8) {
- LPC_GPIO2->DATA = 0xF7F; //2 LED8
- }
- if (i>8) //vorne anfangen bei den LEDs
- {i=1;}
- LPC_TMR32B0->IR = 0x8;//IR quittieren für MR3
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement