Esempio n. 1
0
// Main Function
void main(void)
{ 

  // Initialize System Clocks
  WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
  
  //Clock Setting
  CSCTL1 &= ~(DCORSEL_7);                 // Clear DCO frequency select bits first
  CSCTL1 |= DCORSEL_3;                    // Set DCO = 8MHz, max in G6021
  CSCTL2 = FLLD_0 + 243;                  // DCODIV = 8MHz
  CSCTL3 |= SELREF__REFOCLK;              // Set REFO as FLL reference source
  CSCTL4 = SELMS__DCOCLKDIV | SELREF__REFOCLK; // set default REFO(~32768Hz) as ACLK source, ACLK = 32768Hz
  CSCTL5 |= DIVM_0 | DIVS_0;              // SMCLK = MCLK = DCODIV/1 = 8MHz

  // Initializing GPIO
  P8DIR |= BIT1;                         //Set the pin controlling the center LED P8.1  as output pin
  PM5CTL0 &= ~LOCKLPM5;


  // Initialize Baseline measurement
  TI_CAPT_Init_Baseline(&one_button);
  
  //TI_CAPT_Init_Baseline(&one_button);

   //Update baseline measurement (Average 100 measurements)
  
  TI_CAPT_Update_Baseline(&one_button,100);

  // Main loop starts here
  while (1)
  {
  	
  	#ifdef ELEMENT_CHARACTERIZATION_MODE
	// Get the raw delta counts for element characterization 
	TI_CAPT_Custom(&one_button,&dCnt);
	__no_operation(); 					// Set breakpoint here	
	#endif
	  	
	#ifndef ELEMENT_CHARACTERIZATION_MODE	  	
	// Check if the middle element sensor has been triggered. The API call
	// compares the value from the sensor against the threshold to determine
	// trigger condition

	if(TI_CAPT_Button(&one_button))
	{
		// Do something
		P8OUT |= BIT1;                            // Turn on center LED
	}
	else
	{
		P8OUT &= ~BIT1;                           // Turn off center LED
	}
	
    // Put the MSP430 into LPM3 for a certain DELAY period
    sleep(DELAY);
    #endif
  }
} // End Main
Esempio n. 2
0
File: main.c Progetto: esmil/SLAA419
// Main Function
void main(void)
{ 

  // Initialize System Clocks
  WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
  BCSCTL1 = CALBC1_1MHZ;                // Set DCO to 1, 8, 12 or 16MHz
  DCOCTL = CALDCO_1MHZ;
  BCSCTL2 |= DIVS_2;                    // divide SMCLK by 4 for 250khz      
  BCSCTL3 |= LFXT1S_2;                  // LFXT1 = VLO
  
  P1OUT = 0x00;							// Clear Port 1 bits
  P1DIR |= BIT0;						// Set P1.0 as output pin

  P2SEL &= ~(BIT6 + BIT7);				// Configure XIN (P2.6) and XOUT (P2.7) to GPIO
  P2OUT = 0x00;							// Drive all Port 2 pins low
  P2DIR = 0xFF;							// Configure all Port 2 pins outputs

  // Initialize Baseline measurement
  TI_CAPT_Init_Baseline(&one_button);
  
  // Update baseline measurement (Average 5 measurements)
  TI_CAPT_Update_Baseline(&one_button,5);  
  
  // Main loop starts here
  while (1)
  {
  	
  	#ifdef ELEMENT_CHARACTERIZATION_MODE
	// Get the raw delta counts for element characterization 
	TI_CAPT_Custom(&one_button,&dCnt);
	__no_operation(); 					// Set breakpoint here	
	#endif
	  	
	#ifndef ELEMENT_CHARACTERIZATION_MODE	  	
	// Check if the middle element sensor has been triggered. The API call
	// compares the value from the sensor against the threshold to determine
	// trigger condition  	
	if(TI_CAPT_Button(&one_button))
	{
		// Do something
		P1OUT |= BIT0;                            // Turn on center LED   
	}
	else
	{
		P1OUT &= ~BIT0;                           // Turn off center LED 
	}
	
    // Put the MSP430 into LPM3 for a certain DELAY period
    sleep(DELAY);		
    #endif

  }
} // End Main
Esempio n. 3
0
// Main Function
void main(void)
{ 

  // Initialize System Clocks
  WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
  
  //Clock Setting
  CSCTL0_H = 0xA5;                          // Unlock CS
  CSCTL1 = DCORSEL + DCOFSEL_5;             // Set DCO = 20MHz, use this clk when fRO
  CSCTL2 = SELA__VLOCLK + SELS_3 + SELM_3;  // set SMCLK = MCLK = DCO  LFXT1 = VLO
  CSCTL0_H = 0;                             // Lock CS registers

  P4DIR |= BIT2;						// Set the pin controlling the center LED P4.2  as output pin

  // Initialize Baseline measurement
  TI_CAPT_Init_Baseline(&one_button);
  
  // Update baseline measurement (Average 5 measurements)
  TI_CAPT_Update_Baseline(&one_button,5);  
  
  // Main loop starts here
  while (1)
  {
  	
  	#ifdef ELEMENT_CHARACTERIZATION_MODE
	// Get the raw delta counts for element characterization 
	TI_CAPT_Custom(&one_button,&dCnt);
	__no_operation(); 					// Set breakpoint here	
	#endif
	  	
	#ifndef ELEMENT_CHARACTERIZATION_MODE	  	
	// Check if the middle element sensor has been triggered. The API call
	// compares the value from the sensor against the threshold to determine
	// trigger condition

	if(TI_CAPT_Button(&one_button))
	{
		// Do something
		P4OUT |= BIT2;                            // Turn on center LED
	}
	else
	{
		P4OUT &= ~BIT2;                           // Turn off center LED
	}
	
    // Put the MSP430 into LPM3 for a certain DELAY period
    sleep(DELAY);
    #endif
  }
} // End Main
Esempio n. 4
0
// Main Function
void main(void)
{ 
  WDTCTL = WDTPW + WDTHOLD;             // Stop watchdog timer
  
  // establish baseline
  TI_CAPT_Init_Baseline(&slider);
  TI_CAPT_Update_Baseline(&slider,5);
  TI_CAPT_Init_Baseline(&menu);
  TI_CAPT_Update_Baseline(&menu,5);
  TI_CAPT_Init_Baseline(&power);
  TI_CAPT_Update_Baseline(&power,5);


  // Main loop starts here
  while (1)
  {
    // TI_CAPT_Raw(&slider,Cnt);
	// TI_CAPT_Custom(&slider,Cnt);
    position = TI_CAPT_Slider(&slider);
	direction = (struct Element*)TI_CAPT_Buttons(&menu);
	if(TI_CAPT_Button(&power))
	{
	    __no_operation();
	}
	if(direction == (struct Element*)&right)
	{
	    __no_operation();
	}
	if(direction == (struct Element*)&left);
	{
	    __no_operation();
	}
    if(position != ILLEGAL_SLIDER_WHEEL_POSITION)   
    {
        __no_operation();
    }
    __delay_cycles(100); 
  }
} // End Main