MSP430G2231
Why does this code work:
MOV.B #00h,&BCSCTL2 ;DCO CLK USED FOR CLK AND SMCLK
MOV.B #10000000b,&BCSCTL1 ;SET DCO TO 100 KHZ
MOV.B #00000000b,&DCOCTL
BIS.W #4h,&TACTL ;RESET TIMER
MOV.W #210h,&TACTL ;TIMER USES SMCLK, UPMODE
MOV.W #0010h,&TACCTL0 ;COMPARE MODE; ENABLE INTERRUPT
MOV.W #60000,&TACCR0 ;COUNT UP VALUE (0.5 SEC. WITH 100 KHZ CLK)
BIS.W #0078h,SR ;LPM, CPU OFF, MASKED INTERRUPTS ENABLED
;
;
;
INTERRUPT BIC.W #0010h,0(SP) ;activate CPU after LPM
MOV.W #CONTINUE,2(SP) ;Location to go after interrupt return
RETI ;clear LPM mode
But this code doesn't work (it actually harms the processor where a new code cannot be downloaded through the JTAG):
MOV.B #00h,&BCSCTL2 ;DCO CLK USED FOR CLK AND SMCLK
MOV.B #10000000b,&BCSCTL1 ;SET DCO TO 100 KHZ
MOV.B #00000000b,&DCOCTL
MOV.B #20h,&BCSCTL3 ;USE VLOCLK AS ACLK
BIS.W #4h,&TACTL ;RESET TIMER
MOV.W #110h,&TACTL ;TIMER USES ACLK, UPMODE
MOV.W #0010h,&TACCTL0 ;COMPARE MODE; ENABLE INTERRUPT
MOV.W #6850,&TACCR0 ;COUNT UP VALUE (0.5 SEC. WITH 12 KHZ CLK)
BIC.B #30h,&BCSCTL1 ;MAKE SURE ACLK DIVIDE BY IS 1
BIS.W #00D8h,SR ;LPM, VLOCLK ON, CPU OFF, MASKED INTERRUPTS ENABLED
;
;
;
INTERRUPT BIC.W #00F0h,0(SP) ;ON: SMCLK, DCO, OSCS, CPU activate CPU after low power mode
MOV.W #CONTINUE,2(SP) ) ;Location to go after interrupt return
RETI ;clear LPM mode
_________________________________________________________________
The code differences are in yellow highlight. All of lines in the code are exactly the same. Note: Processor enters a low power mode and Timer A then is used for wake-up from low power mode.