#include /* common defines and macros */ #include /* derivative information */ #pragma LINK_INFO DERIVATIVE "mc9s12c32" //SW1 on PORTE_BIT0 Note:SW1 high when not pressed, low when pressed. #define SW1 PORTE_BIT0 //SW2 on PTP_PTP5 Note:SW2 high when not pressed, low when pressed. #define SW2 PTP_PTP5 //LED1 on PORTA_BIT0 Note: LED1 ON when Bit #0 of PORTA is low. #define LED1 PORTA_BIT0 //LED2 on PORTB_BIT4 Note: LED2 ON when Bit #4 of PORTB is low. #define LED2 PORTB_BIT4 void main(void) { long int i; while(1) { DDRB_BIT4=1; DDRA_BIT0=1; DDRP_DDRP5=0; if(SW1) { LED1=1; //If SW1 not pressed, turn OFF LED1 } else { LED1=0; //If SW1 pressed, turn ON LED1 } if(SW2) LED2=1; //If SW2 not pressed (Hi), turn OFF LED2 else{ //If SW2 pressed (Low), flash LED on and off at 1 Hz rate LED2=0; //Turn ON LED2 for(i=0;i<200000;i++); //Wait 1 second LED2=1; //Turn OFF LED2 for(i=0;i<200000;i++); //Wait 1 second } } }