#include "./MSP430FR5xx_6xx/driverlib.h" #include //#include void initClock(void); void timer_delay(uint32_t); int flag1 = 0,flag2 = 0; int count = 0; volatile int SW1_state=1,SW2_state=1; int main(void) { volatile uint32_t i; volatile uint8_t SW1,SW2; volatile uint16_t SW1_interrupt=1,SW2_interrupt=1,SW1_interrupt_pre,SW2_interrupt_pre; volatile uint32_t delay = 0; // Stop watchdog timer WDT_A_hold(WDT_A_BASE); initClock(); GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN0); // Set Red LED output GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN0); // Red LED off GPIO_setAsOutputPin(GPIO_PORT_P1, GPIO_PIN1); // Set Green LED output GPIO_setOutputLowOnPin(GPIO_PORT_P1, GPIO_PIN1); // Green LED off GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P5, GPIO_PIN6); // S1 P5.6: PxDIR, PxOUT and PxREN registers GPIO_selectInterruptEdge(GPIO_PORT_P5, GPIO_PIN6,GPIO_HIGH_TO_LOW_TRANSITION); // S1 P5.6: PxIES register GPIO_setAsInputPinWithPullUpResistor(GPIO_PORT_P5, GPIO_PIN5); // S2 P5.5: PxDIR, PxOUT and PxREN registers GPIO_selectInterruptEdge(GPIO_PORT_P5, GPIO_PIN5,GPIO_HIGH_TO_LOW_TRANSITION); // S2 P5.5: PxIES register SW1 = GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN6); SW2 = GPIO_getInputPinValue(GPIO_PORT_P5,GPIO_PIN5); //SW1_state = SW1 & 0x08; // Disable the GPIO power-on default high-impedance mode to activate previously configured port settings PMM_unlockLPM5(); // Set all P5IFG to zero P5IFG = 0x00; GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN5); GPIO_enableInterrupt(GPIO_PORT_P5, GPIO_PIN6); __bis_SR_register(GIE); // Enable all interrupts //* // Enable Switch interrupt GPIO_clearInterrupt(GPIO_PORT_P5, GPIO_PIN5); GPIO_clearInterrupt(GPIO_PORT_P5, GPIO_PIN6); //*/ SW1_interrupt_pre= GPIO_getInterruptStatus(GPIO_PORT_P5, GPIO_PIN6); SW2_interrupt_pre= GPIO_getInterruptStatus(GPIO_PORT_P5, GPIO_PIN5); } /* Initializes Clock System */ void CS_init() { // LFXT Setup // Set PJ.4 and PJ.5 as Primary Module Function Input. GPIO_setAsPeripheralModuleFunctionInputPin(GPIO_PORT_PJ,GPIO_PIN4 + GPIO_PIN5,GPIO_PRIMARY_MODULE_FUNCTION); CS_setExternalClockSource(32768, 0); //void CS_setExternalClockSource (LFXTCLK_frequency, HFXTCLK_frequency ) both in Hzl // Initializes the XT1 crystal oscillator CS_turnOnLFXT(CS_LFXT_DRIVE_3); // Set DCO frequency to 16MHz CS_setDCOFreq(CS_DCORSEL_1, CS_DCOFSEL_4); // Configure one FRAM wait state as required by the device data sheet for MCLK // operation beyond 8MHz _before_ configuring the clock system. FRCTL0 = FRCTLPW | NWAITS_1; CS_initClockSignal(CS_MCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); CS_initClockSignal(CS_SMCLK,CS_DCOCLK_SELECT,CS_CLOCK_DIVIDER_1); CS_initClockSignal(CS_ACLK,CS_LFXTCLK_SELECT,CS_CLOCK_DIVIDER_1); }