/*
 * main.c
 */
void main() {
	init_pins();
	init_button();
	init_adc();
	init_wdt();
	WDT_delay = CURRENT_DELAY;

 	BCSCTL1 = CALBC1_8MHZ;
	DCOCTL =  CALDCO_8MHZ;

	LCD_setup();
	_bis_SR_register(GIE);	// enable interrupts
	// initialize LCD and say hello a few times :-)
	LCD_init();

	LCD_send_string((char*)msg);

	while(1){
		LCD_put(0x80+40); // cursor to line 2, first position
		snprintf(hex, 20, HEX, (int)colourArray[1], (int)colourArray[2], (int)colourArray[0]);
		LCD_send_string(hex);
	}

	_bis_SR_register(LPM0_bits);

	//delay(0); // maximum delay



}
// MAIN PROGRAM (SYSTEM RESET HANDLER)
void main(void)	// only one .c file may contain main
{
	// clock initializers
	WDTCTL 	 = WDTPW + WDTHOLD;	// stop the WDT
	BCSCTL1  = CALBC1_16MHZ;	// calibration for basic clock system
	DCOCTL 	 = CALDCO_16MHZ;	// calibration for digitally controlled oscillator

	// TACC0 initializer (generates tripled frequency)
	TACCTL0  = OUTMOD_4 + CCIE;	// toggle output, compare mode, interrupt enabled
	TACCR0	 = half_period;		// initial half period
	P1SEL	|= TA0_BIT;			// connect TACC0 to P1.1
	P1DIR	|= TA0_BIT;			// set P1.1 to output

	// TACC1 initializer (captures input frequency)
	TACCTL1  = (CM_1 +			// capture on rising edge
				CCIS_0 +		// CC input select (CCI1A)
				SCS +			// synchronous capture
	//			SCCI +			// synchronized CC input
				CAP +			// capture mode
				CCIE);			// interrupt enabled
	P1SEL	|= TA1_BIT;			// connect TACC1 to P1.2 as an input

	// timer0_A initializers
	TACTL 	|= TACLR;			// reset TIMER_A
	TACTL 	 = (TASSEL_2 + 		// clock source: SMCLK
				    ID_0 + 		// input divider: 1
				    MC_2);		// continuous mode (interrupt disabled)

	// enable interrupts and put the CPU to sleep
	_bis_SR_register(GIE+LPM0_bits);
}
void main(void) {

	WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    	if (CALBC1_1MHZ==0xFF)   // If calibration constant erased
    	{
    		while(1);          // do not load, trap CPU!!
    	}
    	BCSCTL1 = CALBC1_1MHZ;
    	DCOCTL  = CALDCO_1MHZ;
    	lcdInit(); // Initialize LCD
    	serialInit(); // initalize serial communication
    	//Button Configurations
    	P1DIR &= ~(BIT5 +BIT7);
    	P1REN |= BIT5 + BIT7;

    	//PWM Initialization
    	P1DIR |= BIT6;
    	P1SEL |= BIT6;
    	TA0CTL = TASSEL_2 + MC_1; //SMCLK, up mode
    	TA0CCR0 = period;
    	TA0CCR1 = 0;
    	TA0CCTL1 = OUTMOD_6;
    	WDTCTL = WDT_MDLY_8; //watchdog interrupt every 8 ms
	IE1 |= WDTIE; // ENable Watchdog Tiemr interrupt
	lcdSetText("No Alarm Set.", 0,0);
	alarm_state = 0;
	_bis_SR_register(LPM0_bits+GIE);

}
Example #4
0
// main function
void main(){
	WDTCTL = WDTPW + WDTTMSEL+ WDTCNTCL + 0; // setup using the watchdog timer, using the 8MHz clock, 00 us /32768
	BCSCTL1 = CALBC1_8MHZ;    // 8Mhz calibration for clock
	DCOCTL  = CALDCO_8MHZ;

	init_timer(); 						// initialize timer
	init_button(); 						// initialize the button

	// clear/initialize the global variables
	xaxis_calibrate=0;
	yaxis_calibrate=0;
	x_axis=0;
	y_axis=0;
	z_axis=1;
	count= 100;

	P1REN = BUTTON_BIT;
	P1DIR |= LED_center;	//(BUTTON_BIT+LED_Xaxis+LED_Yaxis+LED_center);
	P1OUT &= ~LED_center;

	init_SPI();
	init_accel();

	IE1 |= WDTIE;			//enable the WDT interrupt

	_bis_SR_register(GIE+LPM0_bits);	// enable general interrupts and power down CPU
}
void main(void) {
	  // setup the watchdog timer as an interval timer
 	  WDTCTL =(WDTPW + // (bits 15-8) password
	                   // bit 7=0 => watchdog timer on
	                   // bit 6=0 => NMI on rising edge (not used here)
	                   // bit 5=0 => RST/NMI pin does a reset (not used here)
	           WDTTMSEL + // (bit 4) select interval timer mode
	           WDTCNTCL +  // (bit 3) clear watchdog timer counter
	  		          0 // bit 2=0 => SMCLK is the source
	  		          +1 // bits 1-0 = 01 => source/8K
	  		   );
	  IE1 |= WDTIE;		// enable the WDT interrupt (in the system interrupt register IE1)

	  P1DIR |= RED+GREEN;					// Set RED and GREEN to output direction
	  P1DIR &= ~BUTTON;						// make sure BUTTON bit is an input
	  
	  counter = 0;
	  arrayIncr = -1;
	  playbackArrayIterator = 0;
	  playbackDownCounter = 0;
	  pushesRecorded = 0;
	  inPlayback = 0; //initialize state to recording mode
	  P1OUT |= RED;  //initialize Red on to start in record mode
	  P1OUT &= ~GREEN;

	  P1OUT |= BUTTON;
	  P1REN |= BUTTON;						// Activate pullup resistors on Button Pin
	  
	  _bis_SR_register(GIE+LPM0_bits);  // enable interrupts and also turn the CPU off!
}
Example #6
0
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    // setup the watchdog timer as an interval timer
   	  WDTCTL =(WDTPW + // (bits 15-8) password
   	                   // bit 7=0 => watchdog timer on
   	                   // bit 6=0 => NMI on rising edge (not used here)
   	                   // bit 5=0 => RST/NMI pin does a reset (not used here)
   	           WDTTMSEL + // (bit 4) select interval timer mode
   	           WDTCNTCL +  // (bit 3) clear watchdog timer counter
   	  		          0 // bit 2=0 => SMCLK is the source
   	  		          +1 // bits 1-0 = 01 => source/8K
   	  		   );

    IE1 |= WDTIE; //Enables Watchdog timer

    P1DIR &= ~BUTTON; //sets the button in the input direction
    P1OUT |= BUTTON;
    P1REN |= BUTTON; //turns on the resistor of the button

    counter = message[indexWord]; //reading the letter from the message array

    _bis_SR_register(GIE+LPM0_bits);  // enable interrupts and also turn the CPU off!

	return 0;
}
Example #7
0
void main(void) {
	  // setup the watchdog timer as an interval timer
	  WDTCTL =(WDTPW + // (bits 15-8) password
	                   // bit 7=0 => watchdog timer on
	                   // bit 6=0 => NMI on rising edge (not used here)
	                   // bit 5=0 => RST/NMI pin does a reset (not used here)
	           WDTTMSEL + // (bit 4) select interval timer mode
	           WDTCNTCL +  // (bit 3) clear watchdog timer counter
	  		          0 // bit 2=0 => SMCLK is the source
	  		          +1 // bits 1-0 = 01 => source/8K
	  		   );
	  IE1 |= WDTIE;		// enable the WDT interrupt (in the system interrupt register IE1)

	  //Variables
	  switchInterval = 300;
	  switchCounter = 0;
	  runCounter = 0;
	  recordIndex = 0;

	  P1DIR |= RED+GREEN;					// Set RED and GREEN to output direction
	  P1DIR &= ~BUTTON;						// make sure BUTTON bit is an input

	  P1OUT |= GREEN+RED; // Green on
	  //P1OUT &= ~RED;  // Red off
	  P1OUT &= ~GREEN;

	  P1OUT |= BUTTON;
	  P1REN |= BUTTON;						// Activate pullup resistors on Button Pin

	  _bis_SR_register(GIE+LPM0_bits);  // enable interrupts and also turn the CPU off!
}
Example #8
0
int main(void)
{
	CLK_init();
	SYS_init();
	UART_init();
	ADC_init();
	PWM_init();			//Initialize PWM (servos not running)
	PWM_dutySet(500, 200);

	_bis_SR_register(LPM0_bits + GIE); // interrupts enabled

	while(1)
	{

		//_ldrL_ADCVal = _readADC(INCH_4); 		//Read ADC input on P2.1
		//_ldrR_ADCVal = _readADC(INCH_5); 		//Read ADC input on P2.2

		UART_puts((char *)"\n\r");
		UART_puts((char *)"_ldrL_ADCVal: ");
		UART_outdec(_ldrL_ADCVal, 0);
		UART_puts((char *)"\n\r");
		UART_puts((char *)"_ldrR_ADCVal: ");
		UART_outdec(_ldrR_ADCVal, 0);

		_delay_cycles(125000);
		P1OUT ^= (BIT0 + BIT6);
	}
}
Example #9
0
File: SPI.c Project: leonasd/SD_ADC
unsigned char SPI_RxFrame(unsigned char *pBuffer, unsigned int size)
{
    if(size ==0 )                        return  (1);
    if(UCA0STAT & UCBUSY)    return  (0);
    _disable_interrupts();
    SPI_Rx_Or_Tx = 0;
    SPI_Rx_Buffer = pBuffer;
    SPI_Rx_Size = size - 1;
    SPI_Interrupt_Sel(SPI_Rx_Or_Tx);
    _enable_interrupts();
    UCA0TXBUF = 0xff;             //在接收模式下,也先发送一次空字节,一遍提供时钟通信

    _bis_SR_register(LPM0_bits);

//	unsigned int gie = _get_SR_register() & GIE;
//	IFG2 &= ~UCA0RXIFG;
//
//	while(size--)
//	{
//		while( !(IFG2 & UCA0TXIFG) );
//		UCA0TXBUF = 0xff;
//		while( !(IFG2 & UCA0RXIFG) );
//		*pBuffer++ = UCA0RXBUF;
//	}
    return 1;
}
Example #10
0
int main(void)
{
	BCSCTL1 = CALBC1_1MHZ;
	DCOCTL  = CALDCO_1MHZ;
	Max1.index = -1;
	Max1.magnitude = 0;
	Max2.index = -1;
	Max2.magnitude = 0;


	// setup the watchdog timer as an interval timer
	WDTCTL =(WDTPW +	// (bits 15-8) password
	                    // bit 7=0 => watchdog timer on
	                    // bit 6=0 => NMI on rising edge (not used here)
	                    // bit 5=0 => RST/NMI pin does a reset (not used here)
	       WDTTMSEL +   // (bit 4) select interval timer mode
	       WDTCNTCL + 	// (bit 3) clear watchdog timer counter
	  		            // bit 2=0 => SMCLK is the source
	  		   2        // bits 1-0 = 10 => source/512 .
	);

	IE1 |= WDTIE;		// enable the WDT interrupt (in the system interrupt register IE1)

	 // in the CPU status register, set bits:
	 //    GIE == CPU general interrupt enable
	 //    LPM0_bits == bit to set for CPUOFF (which is low power mode 0)

	setup_adc();

	init_pwm_timer0(PWM_PERIOD, 0, BIT2); //Pin 2, port of port A. Initially off
	init_pwm_timer1((PWM_PERIOD*1.5), 0, BIT4);

	_bis_SR_register(GIE/*+LPM0_bits*/);  // after execution of this instruction, the CPU is off!
}
Example #11
0
File: SPI.c Project: leonasd/SD_ADC
unsigned char SPI_TxFrame(unsigned char *pBuffer, unsigned int size)
{
    if(size ==0 )            return  (1);
    if(UCA0STAT & UCBUSY)    return  (0);
    _disable_interrupts();
    SPI_Rx_Or_Tx = 1;
    SPI_Tx_Buffer = pBuffer;
    SPI_Tx_Size = size - 1;
    SPI_Interrupt_Sel(SPI_Rx_Or_Tx);
    //__enable_interrupt();
    UCA0IFG &= ~(UCTXIFG + UCRXIFG);
    __bis_SR_register(GIE);
    UCA0TXBUF = *SPI_Tx_Buffer;

    _bis_SR_register(LPM0_bits);

//	unsigned int gie = _get_SR_register() & GIE;
//
//	while(size--)
//	{
//		while( !(IFG2 & UCA0TXIFG) );
//		UCA0TXBUF = *pBuffer++;
//	}
//	while(UCA0STAT & UCBUSY);
//	UCA0RXBUF;
//	_bis_SR_register(gie);
    return  (1);
}
void main(void)
{
	char temp_disp,i;
    WDTCTL = WDTPW + WDTHOLD;
	//TLC initialization
	P1DIR = 0;
    P1DIR |= (SIN5916 + SCLK5916 + LTCH5916);
    P1OUT=0;
	InitializeClocks();						  // Setup clock
    _bis_SR_register(GIE);

	while (1)
    {
		SendData();
		P1OUT|=LTCH5916;
        P1OUT&=~(LTCH5916);
        _delay_cycles(10000);
        temp_disp=disp_arr[0];
        for(i=0;i<N_channel-1;i++)
        {
        disp_arr[i]=disp_arr[i+1];
        }
        disp_arr[N_channel-1]=temp_disp;
    }

}
Example #13
0
void main(){

	WDTCTL = WDTPW + WDTHOLD;       // Stop watchdog timer
	BCSCTL1 = CALBC1_8MHZ;			// 8Mhz calibration for clock
  	DCOCTL  = CALDCO_8MHZ;

  	adc_val = 0;   // most recent result is stored in photo.whole_int
  	updates=0; 		//update counter for debugger
  	last_updates=0; // initialize last_update to 0 like updates value
  	data_send = 0;
  	counter = COUNTER_VAL;
  	low = 29;
  	med = 46;
  	high = 53;
  	light_range = high - low;
  	light_to_pot_factor = (double)light_range / 128.0;
  	state = high_state;
  	beat_count = 0;
  	reached_high = 0;	// set to false
  	reached_low = 0;	// set to false

  	init_spi();
  	init_wdt();
  	init_adc();
  	init_timer();

  	start_conversion();		// do a conversion so that updates > last_updates
  	TACCTL0 |= OUTMOD_4; // turn on speaker
 	_bis_SR_register(GIE+LPM0_bits);

}
Example #14
0
void main(){
	// setup the watchdog timer as an interval timer
	WDTCTL =(WDTPW + 	// (bits 15-8) password
						// bit 7=0 => watchdog timer on
						// bit 6=0 => NMI on rising edge (not used here)
						// bit 5=0 => RST/NMI pin does a reset (not used here)
			WDTTMSEL + 	// (bit 4) select interval timer mode
			WDTCNTCL +  // (bit 3) clear watchdog timer counter
			0 + 		// bit 2=0 => SMCLK is the source
			1); 		// bits 1-0 = 01 => source/8K

	IE1 |= WDTIE;		// enable the WDT interrupt (in the system interrupt register IE1)

	BCSCTL1 = CALBC1_8MHZ; // 8Mhz calibration for clock
	DCOCTL = CALDCO_8MHZ;

	// initialize the WDT variables
	startDelay = 0;
	delayCounter = 0;
	delayInterval = 1;

	init_timer(); // initialize timer
	init_button(); // initialize buttons
	_bis_SR_register(GIE+LPM0_bits); // enable CPU interrupts and power off CPU
}
Example #15
0
void Aufgabe16()
{
    // Alle LEDs aus
    SET(P4OUT, (BIT0 | BIT1 | BIT2));
      
    powerState = LPM_4;
    
    // Taster 0 interruptfähig schalten
    CLEAR(P1IFG, TASTE0);
    // Flanke auf 0 -> Interrupt beim drücken (statt loslassen)
    // fürdie invertierten Taster entspricht dies einer HF
    CLEAR(P1IES, TASTE0);
    SET(P1IE, TASTE0);
         
    // Interrupts global einschalten
    _bis_SR_register(GIE);
    
    while(true) {
        if( powerState == ACTIVE ) {
            // Ampel
            LED_SET(LED_GELB);
        } else if ( powerState == LPM_4 ) {
            LED_OFF;
            LPM4;
        }
    }
}
void MSP430_LPM_ENTER(void)
{
#ifdef LPM_ENABLED

    /* Turn off the watchdog timer */
    WDTCTL = WDTPW | WDTHOLD;

    /*
     * Enter a critical section to do so that we do not get switched out by the
     * OS in the middle of stopping the OS Scheduler.
     */
    __disable_interrupt();
    __no_operation();
    DisableRtosTick();

    // Select a nice mode
    int smclk = 1;//IsSmClkInUse();
    if (smclk)
    {
        LPMcurrent = LPM0_bits;
    }
    else
    {
        LPMcurrent = LPM3_bits;
    }
    MCLK_DIV(2);	// Errata PMM11

    sleep++;
    if (sleep == 5)
    {
        __no_operation();
    }
    //__enable_interrupt();
    int state = LPMcurrent | GIE;
    _bis_SR_register(state);
    __no_operation();
    wake++;

//  if (!smclk)
    {
        /* errata PMM11 - wait to put MCLK into normal mode */
        __delay_cycles(100);
        MCLK_DIV(1);
    }

    /* Generate a vTickIsr by setting the flag to trigger an interrupt
     * You can't call vTaskIncrementTick and vTaskSwitchContext from within a
     * task so do it with an ISR.  We need to cause an OS tick here so that tasks
     * blocked on an event sent by an ISR will run.  FreeRTOS queues them for
     * the next system tick.
     */
    EnableRtosTick();
    RTOS_TICK_SET_IFG();
    __no_operation();


#endif

}
Example #17
0
/*
 *  ======== Power_idleCPU ========
 */
Void Power_idleCPU()
{
#if defined(__ICC430__)
    __bis_SR_register(Power_module->idleMode);
#else
    _bis_SR_register(Power_module->idleMode);
#endif
    Power_module->newMode = FALSE;
}
Example #18
0
/******************************************************************************************************
 * 名       称:I2C_TxFrame()
 * 功       能:新发送1帧数据
 * 入口参数:*p_Tx :待发送数据的首地址
 * 					   num: 待发送数据的个数
 * 出口参数:无
 * 说       明:只有不BUSY且STOP已复位的情况下才允许发送新的帧
 * 范       例:无
 ******************************************************************************************************/
unsigned char I2C_TxFrame(unsigned char *p_Tx,unsigned char num)
{
	if ((UCB0STAT & UCBUSY)||(UCB0CTL1 & UCTXSTP))		return(0);
 	pTxData = (unsigned char *)p_Tx;     	// 更新数据指针
    TxByteCnt = num;                  					// 更新剩余发送数据个数
    UCB0CTL1 |= UCTR + UCTXSTT;            // I2C Tx位, 软件start condition
    _bis_SR_register(CPUOFF+GIE);       		// 进LPM0模式,开总中断
    return(1);
}
// ++++++++++++++++++++++++++
void main(){
	WDTCTL = WDTPW + WDTHOLD;	// Stop watchdog timer
	BCSCTL1 = CALBC1_8MHZ;    // 8Mhz calibration for clock
	DCOCTL  = CALDCO_8MHZ;

	init_timer();  // initialize timer
	init_button(); // initialize button press
	_bis_SR_register(GIE+LPM0_bits);// enable general interrupts and power down CPU
}
Example #20
0
int main(void)
{
    config();

    while(1)
    {
        _bis_SR_register(LPM3_bits + GIE); //Enter Low Power Mode 3 with interrupts
    }

}
Example #21
0
void main( void){
	BCSCTL1 = CALBC1_1MHZ;
	DCOCTL = CALDCO_1MHZ;
	
	init_wdt();
	init_gpio();
	flash_green_slowly();
	reset_button_input_state();
	_bis_SR_register( GIE + LPM0_bits);
}
Example #22
0
/******************************************************************************************************
 * 名       称:I2C_RxFrame()
 * 功       能:新接收1帧数据
 * 入口参数:*p_Tx :数据待存放的首地址
 * 					   num: 待接收数据的个数
 * 说       明:只有不BUSY且STOP已复位的情况下才允许接收新的帧
 * 范       例:无
 ******************************************************************************************************/
unsigned char I2C_RxFrame(unsigned char *p_Rx,unsigned char num)
{
	if ((UCB0STAT & UCBUSY)||(UCB0CTL1 & UCTXSTP))		return(0);
	pRxData = (unsigned char *)p_Rx;     	// 更新数据指针
	 RxByteCnt= num;                  				// 更新剩余接收数据个数
	 UCB0CTL1 &= ~UCTR;
     UCB0CTL1 |= UCTXSTT;                    		// I2C Rx位, 软件start condition
    _bis_SR_register(CPUOFF+GIE);       	    //  进LPM0模式,开总中断
    return(1);
 }
Example #23
0
void main(){
	WDTCTL=WDTPW+WDTHOLD; // disable WDT for now
	index=0; // initial index for storage of data
	_bis_SR_register(GIE); // enable global interrupts
	while(1){
		count[index++]=run_counter();
		if (index>=N_samples){
			index=0;
		}
	}
}
Example #24
0
void main()
{
	//Set watchdog off and make correct smclk
	WDTCTL = WDTPW + WDTHOLD; 		// Halt the watchdog timer
	BCSCTL1 = CALBC1_16MHZ;   		// 16MHz SMCLK bits.
	DCOCTL  = CALDCO_16MHZ;

	//Initialize Timer0, then turn the CPU off.
	initTimer0();
	initGPIO();
	_bis_SR_register(GIE+LPM0_bits);	// Global interrupts enabled, CPU off
}
Example #25
0
//main program
void main() {

	WDTCTL = WDTPW + WDTHOLD;       // Stop watchdog timer
	BCSCTL1 = CALBC1_1MHZ;
	DCOCTL = CALDCO_1MHZ;

	P1DIR |= RED;					//LED initialization
	P1OUT &= ~RED;

	init_spi();
	_bis_SR_register(GIE + LPM0_bits);
}
Example #26
0
// ===== Main Program =====
void main(){

    WDTCTL = WDTPW + WDTHOLD;       // Stop watchdog timer
    BCSCTL1 = CALBC1_8MHZ;          // 8Mhz calibration for clock
    DCOCTL  = CALDCO_8MHZ;

    init_spi();
    init_wdt();
    init_7seg();

    _bis_SR_register(GIE+LPM0_bits);
}
Example #27
0
//==============================================================
void Aufgabe18()
{
    
    initSecTimer(TIMER_SEC);

    // Interrupts global einschalten
    _bis_SR_register(GIE);

    // Infinite loop
    while(1) {
        LPM3;
    }
}
Example #28
0
int main(void) {
    WDTCTL = WDTPW | WDTHOLD;	// Stop watchdog timer

    BCSCTL1 = CALBC1_8MHZ;    // 8Mhz calibration for clock
    DCOCTL  = CALDCO_8MHZ;

    init_sensors();
    init_wdt();
    init_motors();
    init_lastData();

    _bis_SR_register(GIE+LPM0_bits);	//enable general interrupts and power down CPU
}
Example #29
0
/****************************************************************************
* 名    称:SPI_TxFrame()
* 功    能:3线硬件SPI模式下,发送指定数目的字节缓存
* 入口参数:pBuffer:指向待发送的数组地址
* 					size:待发送的字节数
* 出口参数:0:当前硬件SPI在忙,
* 					1:当前数据已发送完毕,
* 说    明:使用该函数可以发送指定个数的一帧数据
* 使用范例:SPI_TxFrame(CMD,6);	// 从CMD中取出并发送6个字节
****************************************************************************/
unsigned char SPI_TxFrame(unsigned char  *pBuffer, unsigned int  size)
{
	if(size==0)									return (1);
	if(UCB0STAT & UCBUSY)			return	(0);			// 判断硬件SPI正忙,返回0
    _disable_interrupts();											// 关闭总中断
    SPI_Rx_Or_Tx = 1;													// 开启发送模式
    SPI_Tx_Buffer = pBuffer;										// 将发送缓存指向待发送的数组地址
    SPI_Tx_Size = size-1;												// 待发送的数据个数
    SPI_Interrupt_Sel(SPI_Rx_Or_Tx);							// SPI中断开启选择
    _enable_interrupts();	                               				// 开总中断
    UCB0TXBUF = *SPI_Tx_Buffer;								// 先发送第一个字节人工触发第一次"发送"中断
	_bis_SR_register(LPM0_bits);									// 进入低功耗模式0
	//flagTx = 1;
	//while(flagTx);
    return (1);
}
Example #30
0
/*
 *  ======== Power_sleepCPU ========
 */
Void Power_sleepCPU(Power_SleepMode sleepMode)
{
    if (sleepMode == Power_Sleep_LPM4_5) {

        /* call to configured function to prepare device I/Os for shutdown */
        Power_sleepPrepFunction();

        /* do the transition to LPM4.5 ... */
        asm(" MOV.W #0xA510, &0x120");        /* PMMPW | PMMREGOFF -> PMMCTL0 */
#if defined(__ICC430__)
        __bis_SR_register(0xF0);  /* CPUOFF | OSCOFF | SCG0 | SCG1 -> SR */
#else
        _bis_SR_register(0xF0);   /* CPUOFF | OSCOFF | SCG0 | SCG1 -> SR */
#endif
    }
}