我刚拿到一套19193EVB的板子,想试试看板子有没有问题,想写程序通过按下SW2点亮LED2,可是总是没有任何反应,由于刚刚接触硬件,不知道下面的代码哪里有问题,请大家指教!
#include <hidef.h> /* for EnableInterrupts macro */ #include <MC9S08GT60.h> /* include peripheral declarations */
/*define value for led's when on and off*/ #define ON 0 #define OFF 1
/*define value for switches when up (not pressed) and down (pressed)*/ #define UP 1 #define DOWN 0
/*define led's*/ #define LED1 PTDD_PTDD0 #define LED2 PTDD_PTDD1
#define LED3 PTDD_PTDD3 #define LED4 PTDD_PTDD4
/*define switches*/ #define SW1 PTAD_PTAD2 #define SW2 PTAD_PTAD3 #define SW3 PTAD_PTAD4 #define SW4 PTAD_PTAD5
void main(void) { EnableInterrupts; /* enable interrupts */ /* include your code here */ PTADD = 0; //initialize as input (Data Direction Register) PTAPE = 0x3c; //Pullups on upper 2,3,4,5 bits /*initialize bits 0,1,3,4 of Port D as outputs (connected to led's)*/ PTDDD = 0x1b; LED1 = OFF; LED2 = OFF; LED3 = OFF; LED4 = OFF;
for(;;) { __RESET_WATCHDOG(); /* feeds the dog */ LED2 = SW2; } /* loop forever */ }
|