#include  "msp430x41x.h"
;******************************************************************************
;   MSP-FET430P410 Demo - FLL+ LPM3 Using BasicTimer Interrupt, 32kHz ACLK
;  
;   Description: System runs normally in LPM3 with basic timer clocked by 
;   32kHz ACLK. At a 2 second interval the basic timer ISR will wake the 
;   system and flash the LED on P5.1 inside of the Mainloop. If using
;   FET, must release JTAG on go, start, stop and restart application.
;   ACLK = LFXT1 = 32768, MCLK = SMCLK = DCO = 32xACLK = 1.48576MHz
;   //*An external watch crystal is required on XIN/XOUT for ACLK*//	  
;
;                MSP430F413
;             -----------------
;         /|\|              XIN|-  
;          | |                 | 32k
;          --|RST          XOUT|-
;            |                 |
;            |             P5.1|-->LED
;
;   M.Buccini
;   Texas Instruments, Inc
;   January 2002
;******************************************************************************
;------------------------------------------------------------------------------ 
            ORG     0E000h                  ; Program Start
;------------------------------------------------------------------------------ 
RESET       mov.w   #300h,SP                ; Initialize stackpointer
Init_Sys    mov.w   #WDTPW+WDTHOLD,&WDTCTL  ; Stop WDT
SetupFLL    bis.b   #XCAP14PF,&FLL_CTL0     ; Configure load caps
SetupBT     mov.b   #BTDIV+BTIP2+BTIP1+BTIP0,&BTCTL   ; 2s Int. 
            bis.b   #BTIE,&IE2              ; Enable Basic Timer interrupt        
SetupP1     mov.b   #0FFh,&P6DIR            ; P6.x output
            mov.b   #0FFh,&P5DIR            ; P5.x output
            mov.b   #0FFh,&P4DIR            ; P4.x output
            mov.b   #0FFh,&P3DIR            ; P3.x output
            mov.b   #0FFh,&P2DIR            ; P2.x output
            mov.b   #0FFh,&P1DIR            ; P1.x output
            eint                            ; Enable interrupts      
                                            ;				          							  
Mainloop    bis.w   #LPM3,SR                ; Enter LPM3
            bis.b   #002h,&P5OUT            ; Set P5.1
            push    #2000                   ; Delay to TOS
Pulse       dec.w   0(SP)                   ; Decrement Value at TOS
            jnz     Pulse                   ; Delay done?
            incd.w  SP                      ; Clean-up stack
            bic.b   #002h,&P5OUT            ; Reset P5.1
            jmp     Mainloop                ;
                                            ;
;------------------------------------------------------------------------------
BT_ISR;     Exit LPM3 on reti
;------------------------------------------------------------------------------
            bic.w   #LPM3,0(SP)             ; 
            reti                            ;		 
                                            ;   
;----------------------------------------------------------------------------- 
;           Interrupt Vectors Used MSP430F41x         
;----------------------------------------------------------------------------- 
            ORG     0FFFEh                  ; MSP430 RESET Vector
            DW      RESET                   ; 
            ORG     0FFE0h                  ; BT Vector
            DW      BT_ISR                  ; 
            END     
