Question: Give a code not others things and if you cant help dont do it Pick and implement one of the two blinking patterns below: 1

Give a code not others things and if you cant help dont do it
Pick and implement one of the two blinking patterns below:
1. Holiday Blinky simpler coding task for reduced number of points (45/50 pts):
Use periodic interrupts generated by Timer B0(B zero) to make the LEDs to twinkle in a simple
alternating pattern: when the green LED is on the red one should be off and vice versa.
For this task, you do not need to implement a state machine.
2. Waltzing Blinky twinkling LEDs with a state machine (50/50 pts)
The waltz is a ballroom dance with a 1-2-3 rhythm pattern with an accent on the first beat. Use
periodic interrupts generated by Timer B0(B zero) to make the LEDs waltz by blinking red-
green-green-red-green-green... How? Make the red LED blink once followed by two blinks of
the green LED and repeat this pattern indefinitely.
For both tasks:
Please watch the short demo video posted to Carmen exhibiting the desired behaviors.
While the LEDs are twinkling, the MCU is in low power mode (LPM3).
The LEDs are turned on and off while serving interrupts generated by Timer B0, you are
not allowed to utilize any software generated delay loops.
Start by downloading the corresponding asm file from Carmen. In both files, I have already
configured Timer B0 to throw periodic interrupts (only the frequency is different, faster for the
waltz). You will write an ISR that services these interrupts. Make sure that your ISR does not
modify any core registers.
The memory address for the Timer B0 interrupt vector is 0xFFF4. The interrupt flag is bit TBIFG
in the 16-bit register TB0CTL. Make sure to test and clear the TBIFG bit only DO NOT clear
the entire TB0CTL register since it holds information that is critical for the correct operation of
Timer B0.
The holiday_blinky code: ;-------------------------------------------------------------------------------
; MSP430 Assembler Code Template for use with TI Code Composer Studio
;
;
;-------------------------------------------------------------------------------
.cdecls C,LIST,"msp430.h" ; Include device header file
;-------------------------------------------------------------------------------
.def RESET ; Export program entry-point to
; make it known to linker.
;-------------------------------------------------------------------------------
.text ; Assemble into program memory.
.retain ; Override ELF conditional linking
; and retain current section.
.retainrefs ; And retain any sections that have
; references to current section.
;-------------------------------------------------------------------------------
RESET mov.w #__STACK_END,SP ; Initialize stackpointer
StopWDT mov.w #WDTPW|WDTHOLD,&WDTCTL ; Stop watchdog timer
;-------------------------------------------------------------------------------
; Main loop here
;-------------------------------------------------------------------------------
; Configure Timer B0 to throw periodic interrupts
bis.w #TBCLR, &TB0CTL ; reset timer
bis.w #TBSSEL__ACLK, &TB0CTL ; source is ACLK
bis.w #MC__CONTINUOUS, &TB0CTL ; continuous mode
bis.w #CNTL__12, &TB0CTL ; counter length =12 bits
bis.w #ID__4, &TB0CTL ; divide freq. by 4
bis.w #TBIE, &TB0CTL ; enable interrupts
; Add your code here
;-------------------------------------------------------------------------------
; Interrupt Service Routine
;-------------------------------------------------------------------------------
TB0_ISR:
; Add your code here
;-------------------------------------------------------------------------------
; Stack Pointer definition
;-------------------------------------------------------------------------------
.global __STACK_END
.sect .stack
;-------------------------------------------------------

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Electrical Engineering Questions!