TheLegace

Lab1P2

Jan 20th, 2012
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.18 KB | None | 0 0
  1. /***********************************************************************************
  2.  
  3.   York University CSE3215
  4.   Main.c
  5.   Jan 09, 2006
  6.  
  7. ***********************************************************************************/
  8. #include <hidef.h>            /* common defines and macros */
  9. #include <mc9s12dp256.h>      /* MicroController derivative information */
  10. #include <stdint.h>
  11.  
  12.  
  13. #pragma LINK_INFO DERIVATIVE "mc9s12dp256b"
  14.  
  15. void main(void)
  16. {
  17.   /* put your own code here */
  18.   EnableInterrupts;
  19.   DDRB = 0xFF;  //Set PORTB as output
  20.   DDRH = 0x00;  //Set PORTH as input
  21.  
  22.  
  23.  
  24.   for(;;)
  25.   {
  26.      
  27.     if(PTH < 191)
  28.         if(PTH < 127)
  29.             if(PTH<63)
  30.                 if(PTH_PTH0)
  31.                     PORTB = PORTB_BIT1; //set bit1(LED1)
  32.                 else
  33.                     PORTB = PORTB_BIT0; //set bit0(LED0)
  34.             else
  35.                 if(PTH_PTH0)
  36.                     PORTB = PORTB_BIT3; //set bit3(LED3)
  37.                 else
  38.                     PORTB = PORTB_BIT2; //set bit2(LED2)
  39.         else
  40.             if(PTH_PTH0)
  41.                 PORTB = PORTB_BIT5; //set bit5(LED5)
  42.             else
  43.                 PORTB = PORTB_BIT4; //set bit4(LED4)
  44.     else
  45.         if(PTH_PTH0)
  46.             PORTB = PORTB_BIT7; //set bit7(LED7)
  47.         else
  48.             PORTB = PORTB_BIT6; //set bit6(LED6)
  49.      
  50.     /* put more of your code here */
  51.   } /* wait forever */
  52. }
Advertisement
Add Comment
Please, Sign In to add comment