
5-3
MSP430 Microcode Example
;****************************************************************************
;
Set Up 11x
;****************************************************************************
Setup MOV
#WDTPW+WDTHOLD,&WDTCTL
MOV
#TASSEL1+CLR,&TACTL
;stop watchdog timer
;clock source for 16-bit
;timer of Timer_A = SMCLK,
;ACLK/4 for DCO cal,
;current into DCO
; (Rsel=6)
MOV.b
#XTOFF+DIVA1+RSEL2+RSEL0,&BCSCTL1
BIC.b
BIC.b
BIC.b
BIS.b
BIS.b
BIS.b
BIC.b
;setting for Expand = 0 = off
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
CALL
#DELAY2
BIC.b #RST,&P1OUT
#0FFh,&P1SEL
#0FFh,&P2SEL
#0FEh,&P1OUT
#0C1h,&P1DIR
#RST,&P1OUT
#OSC_OE,&P1OUT
#0FFh,&P2OUT
;set P1 function = I/O
;set P2 function = I/O
;set P1 output data = low, except reset
;set P1 pins-I2C & switches = inputs
;set RESET data = high
;set oscill enable data = high
;set P2 output data = low
;delay to let oscill stabilize
;set RESET data = low. pin goes
;low since it is enabled
;delay RESET low to high
;set RESET pin high
Key switch pins & registers
;switch pins on P1 set to inputs
;switch pins on P2 set to inputs
;SW1-3 interrupt edge select = HI to LO
BIS.b #SW4+SW5+SW6,&P2IES
;SW4-6 interrupt edge select = HI to LO
BIS.b #SW1+SW2+SW3,&SW1_3IE ;SW1-3 interrupts enabled
BIS.b #SW4+SW5+SW6,&SW4_6IE ;SW4-6 interrupts enabled
BIS.b #EXP+LED,&P2DIR
;set expand & LED pins to outputs
BIS.b #LED,&LED_OUT
;LED initial state = off (active low)
CALL
BIS.b #RST,&P1OUT
;*********************
BIC.b #SW1+SW2+SW3,&P1DIR
BIC.b #SW4+SW5+SW6,&P2DIR
BIS.b #SW1+SW2+SW3,&P1IES
#NOP9
MOV
MOV
MOV
MOV
MOV
CLR
BIC.b #SW1+SW2+SW3,&SW1_3IF ;clear SW1-3 interrupt flags (P1IFG)
BIC.b #SW4+SW5+SW6,&SW4_6IF ;clear SW4-6 interrupt flags (P2IFG)
RET
;****************************************************************************
;
Delay routine
;****************************************************************************
DELAY0
push
#03000h
;SW Delay using Stack
JMP
DELAY3
DELAY
push
#06000h
;SW Delay using Stack
JMP
DELAY3
DELAY2
push
#09000h
;SW Delay using Stack
DELAY3
dec
0(SP)
;
#180,Vol_Pntr
#415,Bass_Pntr
#415,Bass_Setpnt
#510,Trbl_Pntr
#510,Trbl_Setpnt
MUTE
;initial setting for volume
;initial setting for bass
;initial setting for bass
;initial setting for treble
;initial setting for treble
;set mute = 0 = initial state of mute = off