This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

MSP430F2101: After Timer inttrupt microcontroller resets what could be wrong. its is a simple timer

Part Number: MSP430F2101

;-----------------------------------------------------------------------
#include <msp430x21x1.h> ; Header file for this device
;-----------------------------------------------------------------------
; Pins for LED on port 2
LED1 EQU BIT0 ; Relay port
LED2 EQU BIT1 ; Timer led blinking mode
Start EQU BIT2 ;start of timer
Select EQU BIT3 ;timer selection
#define Display R7
#define Time R6
#define delay 20
;counter EQU 20 ;3*60*10 ; 3 is multiple factor(3*60=1 minute).
;-----------------------------------------------------------------------
RSEG CSTACK ; Create stack (in RAM)
;-----------------------------------------------------------------------
RSEG CODE ; Program goes in code memory
Reset: ; Execution starts here
mov.w #SFE(CSTACK),SP ; Initialize stack pointer
; mov.w #1,R6
; bic.w #GIE,SR
; Equivalent to start of main() in C
main: mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
; mov.b #LED2,&P2OUT ; Preload LED1 on, LED2 off
bic.b #LED1|LED2,&P2OUT
bis.b #LED1|LED2,&P2DIR ; Set pins with LED1,2 to output
bis.b #LED2 ,&P2OUT



bic.b #Start|Select, &P2DIR ; start & select pin direction as input
bis.b #Start|Select, &P2REN ; start & select pin pull up resistor enable
bis.b #Start|Select,&P2OUT ;Make the pull up pull up not down.forever
; mov.w #counter,R5
mov.w #1,R6 ; initial state of timer

mov.w #delay,&TACCR0 ; Period for up mode
mov.w #CCIE,&TACCTL0 ; Enable interrupts on Compare 0
mov.w #MC_1|ID_3|TASSEL_2|TACLR,&TACTL ; Set up Timer A
bis.w #GIE,SR
dint
; Up mode, divide clock by 8, clock from SMCLK, clear TAR
call #DISPLAY

aa:
; call #Time_Set
; call #Load_Data ; load set time to counter R5
; mov.w #counter,R5
bit.b #Start, &P2IN ; BIT P2.0 CHECK IF PRESSED
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
JNZ aa
mov.w #5400d,R5


aa:
eint
; Loop forever; interrupts do all!
bis.b LED1,&P2OUT ;Relay ON
; call #Sw_Check
; mov.w #5400d,R5
cmp.w #0,R5
jne aa

again:
dint
; bic.w #GIE,SR ; Disable interrupts
bic.b #LED1,&P2OUT ;Relay OFF
bis.b #LED2,&P2OUT

jmp main

DELAY_1S:
ret

mov.w #65000,R12 ;value should be >2500
d1: dec.w R5
jnz d1
ret
;////////////////////////////////////////////////////////////////////
Time_Set:
bit.b #Select, &P2IN ; BIT P2.0 CHECK IF PRESSED
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
JZ Setup
jmp Exit
Setup:
inc Time
; call #DISPLAY
cmp #9,Time
jne Exit
mov #1,Time
Exit:
call #DISPLAY
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
ret

;////////////////////////////////////////////////////////////////////
/*
Load_Data :
mov.w (Data_Load)(R6),R5
; mov.b DispReg,&P1OUT
ret
*/
;//////////////////////////////////////////////////////////////////

DISPLAY:
mov.b (Data_Dis)(R6),&P1OUT
; mov.w (Data_Load)(R6),R5 ; time loaded to counter
cmp #1,R6
JZ One
cmp #2,R6
JZ Two
cmp #3,R6
JZ Three
cmp #4,R6
JZ Four
cmp #5,R6
JZ Five
cmp #6,R6
JZ Six
cmp #7,R6
JZ Seven
cmp #8,R6
JZ Eight

One:
mov.w #5400d,R5 ;30 mins (=3*60*30)
ret
Two:
mov.w #10800d,R5 ;1 Hour
ret
Three:
mov.w #16200d,R5 ;1.5 Hour
ret
Four:
mov.w #21600d,R5 ;2 Hour
ret
Five:
mov.w #27000d,R5 ;2.5 Hour
ret
Six:
mov.w #32400d,R5 ;3 Hour
ret
Seven:
mov.w #37800d,R5 ;3.5 Hour
ret
Eight:
mov.w #43200d,R5 ;4 Hour
ret
;/////////////////////////////////////////////////////////////////
/*
Sw_Check:
bit.b #Start, &P2IN ; BIT start CHECK IF PRESSED
JZ Check_1
ret

Check_1:
; CALL #DELAY_1S ; DEBOUNCE TIME 1 SEC
bit.b #Start, &P2IN ; BIT start CHECK IF PRESSED
jnz ss
jmp main
ss:
ret
*/
;//////////////////////////////////////////////////////////////////


;ORG 01000h

Data_Dis
DB “0d,1d,2d,4d,8d,16d,32d,64d,128d“


;Data_Load
;DW “0d,5400,10800,16200,21600,27000,32400,37800,43200“


; time is 30,60,90,120,150,180,210,240 minutes
; total time is 4 hours
/*

ORG 01000h

Data_Dis
DB 00000000b
DB 00000001b
DB 00000010b
DB 00000100b
DB 00001000b
DB 00010000b
DB 00100000b
DB 01000000b
DB 10000000b
*/
;////////////////////////////////////////////////////////////////////
;-----------------------------------------------------------------------
; Interrupt service routine for TACCR0, called when TAR = TACCR0
; No need to acknowledge interrupt explicitly - done automatically
TA0_ISR: ; ISR for TACCR0 CCIFG


xor.b #LED2,&P2OUT ; Toggle LEDs
reti ; That's all: return from interrupt
;-----------------------------------------------------------------------
COMMON INTVEC ; Segment for vectors (in Flash)
ORG TIMERA0_VECTOR
DW TA0_ISR ; ISR for TA0 interrupt
ORG RESET_VECTOR
DW Reset ; Address to start execution
END

  • Hi Yogesh,

    I don't recognize some of the symbols you're using throughout the code. More specifically, I'm not confident that you are setting up the interrupt vector correctly in your code. I recommend taking a look at the assembly examples available via the TI Resource Explorer. The example linked below shows how to setup a timer and it's interrupt correctly using assembly language. Can you take a look at it and let me know if it helps?

    dev.ti.com/.../

    Best regards,
    Caleb Overbay
  • Aside from what Caleb mentioned, if your controller is controlling a relay, make sure that you are not having any power surges/issues on the I/O and VCC.
  • Hi Yogesh,

    Have you made any progress on this issue? If so, can you share for others who may be experiencing similar issues?

    Best regards,
    Caleb Overbay

**Attention** This is a public forum