A nyomógombok és a LED-ek a PORTF porton keresztül kezelhetoek. //******************************************** //******************************************** // // Definitions for LEDs and push buttons // //********************************************* //********************************************* //PORTF: // |1 1 1 1 | 1 1 | | | // |5 4 3 2 | 1 0 9 8 | 7 6 5 4 | 3 2 1 0 | // |--------|---------|---------|---------| // | | | | | // |x x x x | L L L L | L L P P | P P x x | // |x x x x | E E E E | E E B B | B B x x | // |x x x x | D D D D | D D 4 3 | 2 1 x x | // | | 6 5 4 3 | 2 1 | | // | | | | | // // // #include //mask for LEDs #define LED_MASK (0x0FC0) //mask for push buttons #define PB_MASK (0x003C) #define LED1_PORTF (0x0040) #define LED2_PORTF (0x0080) #define LED3_PORTF (0x0100) #define LED4_PORTF (0x0200) #define LED5_PORTF (0x0400) #define LED6_PORTF (0x0800) #define LED_ALL (LED1_PORTF|LED2_PORTF|LED3_PORTF|LED4_PORTF|LED5_PORTF|LED6_PORTF) #define PB1_PORTF (0x0004) #define PB2_PORTF (0x0008) #define PB3_PORTF (0x0010) #define PB4_PORTF (0x0020) #define PB_ALL (PB1_PORTF|PB2_PORTF|PB3_PORTF|PB4_PORTF) // ------ END of definitions for LEDs and push buttons ------ int iPortflag; //F port beolvasasa iPortflag=*pPORTFIO; //Torlunk minden esetleges megszakitaskerest. *pPORTFIO_CLEAR = PB_MASK; // A LED-ek allapotanak beallitasanak modja a kovetkezo: // 1. *pPORTFIO_SET regiszter sergisegevel beallitjuk az 1-es biteket // 2. *pPORTFIO_CLEAR regiszter sergisegevel toroljuk a 0-as biteket // Azert tortenik igy a beallitas, mert ezzel a modszerrel nem valtozik a tobbi bit allapota //Pelda: // *pPORTFIO_SET = iLEDState&LED_MASK; //set the bits // *pPORTFIO_CLEAR = (~iLEDState)&LED_MASK; //clear the bits