Example #1
0
int main(void)
{
  const int LED_HZ = 10;

  WDTCTL = WDTPW + WDTHOLD;	// Stop WDT

  led_init();

  BCSCTL3 |= LFXT1S_2;	//Set ACLK to use internal VLO (12 kHz clock)

  TACTL = TASSEL__ACLK | MC__UP;	//Set TimerA to use auxiliary clock in UP mode
  TACCTL0 = CCIE;	//Enable the interrupt for TACCR0 match
  TACCR0 = 12*1024 / LED_HZ;
	/*Set TACCR0 which also starts the timer. At
				12 kHz, counting to 12000 should output
				an LED change every 1 second. Try this
				out and see how inaccurate the VLO can be */
			
  WRITE_SR(GIE);	//Enable global interrupts

  int bitnum = 0;
  int pattern = 0b11100100;

  while (1) {
    while (!Gloop_flag);
    Gloop_flag = 0;

    bitnum++;
    if (bitnum > 8) {
      bitnum = 0;
    }
    Gled_on = pattern & (1 << bitnum);
  }
}
Example #2
0
int main(void) {

  WDTCTL = WDTPW + WDTHOLD;	// Stop WDT
  /*Halt the watchdog timer
      According to the datasheet the watchdog timer
      starts automatically after powerup. It must be
      configured or halted at the beginning of code
      execution to avoid a system reset. Furthermore,
      the watchdog timer register (WDTCTL) is
      password protected, and requires the upper byte
      during write operations to be 0x5A, which is the
      value associated with WDTPW.*/

  initLEDs();		//Setup LEDs

  BCSCTL3 |= LFXT1S_2;	//Set ACLK to use internal VLO (12 kHz clock)

  TACTL = TASSEL__ACLK | MC__UP;	//Set TimerA to use auxiliary clock in UP mode
  TACCTL0 = CCIE;	//Enable the interrupt for TACCR0 match
  TACCR0 = 11999;	/*Set TACCR0 which also starts the timer. At
				12 kHz, counting to 12000 should output
				an LED change every 1 second. Try this
				out and see how inaccurate the VLO can be */
			
  WRITE_SR(GIE);	//Enable global interrupts

  while(1) {
	//Loop forever, interrupts take care of the rest
  }
}
Example #3
0
int main(void)
{
  /* Watchdog timer disabled */
  WDTCTL = WDTPW + WDTHOLD;
  
  BspInit();
  DioInit();
  TimerInit(10);                         // 0.1ms tick, 1 timed task, 0 loop task
  WRITE_SR(GIE);       // Enable global interrupts
  __eint();
  LcdInit();

  BspReset();         // if ever we get here, we have nothing better to do but reset the micro
  while(1)
  {
  }
}
Example #4
0
int main(void) {

  DCOCTL = 0x7<<4; // Set to 21MHz
  BCSCTL1 |= 0xf;
  WDTCTL = WDT_MDLY_32;
  IE1 |= WDTIE;

  P1DIR |= BIT6 + BIT0;
  P1DIR &= ~BIT3;

  BCSCTL2 |= BIT1;
  BCSCTL3 |= LFXT1S_2;	//Set ACLK to use internal VLO (12 kHz clock)

  TACTL = TASSEL_2 | MC_1;	//Set TimerA to use auxiliary clock in UP mode

  WRITE_SR(GIE);	//Enable global interrupts

  char isPressed = 0;
  while(1) {
	//Loop forever, interrupts take care of the rest
	if(!(P1IN & BIT3)){
		if(!isPressed)
			isPressed = 1;
		else
			isPressed = 2;
	}else{
		isPressed = 0;
  	}

	if(isPressed == 1){
		musicOn = musicOn?0:1;

		if(!musicOn){
			musicIdx = 0;
		}	
	}
  }

}
int main(void) {
    const int LED_HZ = 10;

    WDTCTL = WDTPW + WDTHOLD;	// Stop WDT

    initLEDs();		//Setup LEDs

    BCSCTL3 |= LFXT1S_2;	//Set ACLK to use internal VLO (12 kHz clock)

    TACTL = TASSEL__ACLK | MC__UP;	//Set TimerA to use auxiliary clock in UP mode
    TACCTL0 = CCIE;	//Enable the interrupt for TACCR0 match
    TACCR0 = 12*1024 / LED_HZ;
    /*Set TACCR0 which also starts the timer. At
    			12 kHz, counting to 12000 should output
    			an LED change every 1 second. Try this
    			out and see how inaccurate the VLO can be */

    WRITE_SR(GIE);	//Enable global interrupts

    while(1) {
        //Loop forever, interrupts take care of the rest
    }
}
Example #6
0
int main(void)
{
  /* Watchdog timer disabled */
  WDTCTL = WDTPW + WDTHOLD;
  set_letter('B');
  initPorts();
  LED_OUT &= ~(LED0);

  BCSCTL3 |= LFXT1S_2; 	// Use slow oscillator (12kHz)

  TACTL = 0x0200 + TAIE + MC_3 + ID_3; //0x0200 = SMCLK
  TACCTL0 = CCIE;
  TACCR0 = 99;

  WRITE_SR(GIE);       // Enable global interrupts

  test_blink(P1OUT_, LED0);
  //LED_OUT^= 0xff;
  while(1)
  {
    //Loop forever
    
  }
}