Example #1
0
/**********************************************************************//**
 * @brief  turn on LED1 and blink it every second until user touch the capsense
 *
 * @param  none
 *
 * @return none
 *************************************************************************/
void onLED(void)
{
    // configure RTC interrupt every second
    RTC_B_definePrescaleEvent(__MSP430_BASEADDRESS_RTC_B__, RTC_B_PRESCALE_1, RTC_B_PSEVENTDIVIDER_128);
    RTC_B_enableInterrupt(__MSP430_BASEADDRESS_RTC_B__, RTC_B_PRESCALE_TIMER1_INTERRUPT);
    RTC_B_startClock(__MSP430_BASEADDRESS_RTC_B__);
    startupStatus = 1;

}
void System_Init(void)
{
	/* Calendar struct */
	sCalendar calendar;

	/* Stop watchdog timer */
	WDTCTL = WDTPW | WDTHOLD;
	/* Systyem Clock */
	/* Enabled  XT1 Crystal */
	PJSEL0 |= BIT4 + BIT5;
	/* Write Password */
	CSCTL0_H = 0xA5;
	CSCTL1 |= DCOFSEL0 + DCOFSEL1 + DCORSEL;	// Set max. DCO setting, 24 MHz
	CSCTL2 = SELA_0 + SELS_3 + SELM_3;			// set ACLK = XT1; MCLK = DCO
	CSCTL3 = DIVA__8 + DIVS_0 + DIVM_0;			// set all dividers
	CSCTL4 |= XT1DRIVE_0;
	CSCTL4 &= ~XT1OFF;
	do
	{
		CSCTL5 &= ~XT1OFFG;
		/* Clear XT1 fault flag */
		SFRIFG1 &= ~OFIFG;
	}while (SFRIFG1 & OFIFG);                   // Test oscillator fault flag

	/* Timer init */
	TA0CTL = (TASSEL_1 + ID_3 + MC_1 /*+ TAIE*/);
	TA0CCR0 = 511;
	TA0CCTL0 = CCIE;

	/* Set start calendar date-time */
	calendar.Year 			= 2015;
	calendar.Month 			= 0;
	calendar.DayOfMonth		= 1;
	calendar.DayOfWeek		= 4;
	calendar.Hours 			= 0;
	calendar.Minutes 		= 0;
	calendar.Seconds 		= 0;

	/* RTC start clock */
	RTC_B_startClock(RTC_B_BASE);
	/* Init RTC calendar */
	RTC_B_initCalendar(RTC_B_BASE, &calendar, RTC_B_FORMAT_BINARY);

	/* Enabled RTC interrupt */
	RTC_B_enableInterrupt(RTC_B_BASE, RTCRDYIE + RTCTEVIE + RTCAIE);

	RTCCTL01 &=~ RTCHOLD;
}