I want to make LED3 stay on for 7 seconds and then blink three times with 1 second oscillation, and then move to LED4. I've already gotten LED3 to stay on for 7 seconds and then go to LED4, but I still don't know how to make it blink those three times. (It is a traffic light).
Code:
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
mov.w #0x0001, r5
mov.w #0x001F, &P3DIR
bisw #MC0|MC1, &TA0CTL ; Timer up/down
bis.w #TACLR, &TA0CTL ; Clear the timer TAR.
bis.w #TASSEL__ACLK, &TA0CTL ; Use ACLK (32 KHz).
bis.w #ID0|ID1, &TA0CTL ; Divide by 8.
bic.w #TAIFG, &TA0CTL ; Clear the interrupt flag.
bis.w #TAIE, &TA0CTL ; Enable timer TA0 interrupts.
mov.w #0x0001, &TA0CCR0
nop
bis.w #LPM3|GIE, SR
nop
;interrupts.
TA0_ISR
cmp.w #TA0IV_TAIFG, &TA0IV ; Check if the timer overflowed.
jnz not_correct_flag
cmp.w #0x0001, r5
jz led1 ;overflow.
cmp.w #0x0002, r5
jz led2
cmp.w #0x0003, r5
jz led3
cmp.w #0x0004, r5
jz led4
led1
mov.b #0x0001, &P3OUT ; 0000 0001 = BIT0
bis.b #BIT1, &P3OUT
inc.w r5
mov.w #0x5000, &TA0CCR0
reti
led2
mov.b #0x0002, &P3OUT ; 0000 0010 = BIT1
inc.w r5
mov.w #0x5000, &TA0CCR0
reti
led3
mov.w #0x0004, &P3OUT ; 0000 0100 = BIT2
inc.w r5
mov.w #0x3800, &TA0CCR0
reti
led4
mov.b #0x0008, &P3OUT ; 0000 10000 = BIT3
mov.w #0x0001, r5
mov.w #0x5000, &TA0CCR0
reti
not_correct_flag
bic.w #TAIFG, &TA0CTL ; This is the ISR. Clear interrupt flag
reti
;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
.global __STACK_END
.sect .stack
;-------------------------------------------------------------------------------
; Interrupt Vectors
;-------------------------------------------------------------------------------
.sect ".reset"
.short RESET
.sect ".int52"
.short TA0_ISR
.end