Question: Mode 0 Red LED blinks every 1 / 2 a second ( using execution loop ) Mode 1 Red LED blinks every 1 / 2
Mode
Red LED blinks every a second using execution loop
Mode
Red LED blinks every second using execution loop
Green LED blinks every second using timer & interrupt
Mode
Red LED turns off
Green LED blinks every second using timer & interrupt
Blue LED blinks every second using timer & signal
Mode
Red LED stays off
Green LED turns off
Blue LED blinks slower, every second using timer & signal
Objective
For this assignment, you should attempt to recreate the RGB LED activity listed above with the method inside parenthesis. Pressing the button on the Blacktop should advance to the next mode advancing from should go back to and pressing the side button on the Launchpad should step back to the previous mode moving backward from should set the mode to
Because you are using the buttons as interrupts, the completed program will have some initialization, execution loop and three interrupts: one for TIMERAVECTOR, one for PORTVECTOR and one for PORTVECTOR.
Tips
Do not recommend setting hardware parameters in the execution loop based on what mode you are in for instance, checking to see what mode you are in every loop iteration and enabling interrupts for the timer if in Mode or otherwise disabling interrupts if in Mode or
This is a waste of time. You should set hardware parameters when changing modes.
#include
#define PC r
#define SP r
#define SR r
##define CG r
;
; PROGRAM DATA READONLY
section rodata ; this should be placed in ROM
;
DISP: byte b ; pattern for
byte b ; pattern for
byte b ; pattern for
byte b ; pattern for
; PROGRAM DATA READ AND WRITE
section data ; this should be placed in RAM
; PROGRAM INSTRUCTIONS
text ; this section is for instructions
global MAIN
; disable watchdog and run at Mhz
mov #WDTPWWDTHOLD &WDTCTL
mov.b &CALBCMHZ &BCSCTL
mov.b &CALDCOMHZ &DCOCTL
; initialize stack pointer
mov #x SP
; use P and P normally
bic.b #BITBIT &PSEL
bic.b #BITBIT &PSEL
; initialize other things
; TODO: set up display
bis.b # &PDIR
bic.b # &POUT
bis.b #BIT &PDIR
bic.b #BIT &POUT
Files ; TODO: set up P button
bic.b #BIT &PDIR
bis.b #BIT &PIE
bis.b #BIT &PIES
bic.b #BIT &PIFG
; TODO: set up P button
bic.b #BIT &PDIR
bis.b #BIT &PIE
bis.b #BIT &PIES
bic.b #BIT &PIFG
; TODO: green light
bic.b #BIT &PDIR
bic.b #BIT &PUT
; TODO: red light
bis.b #BIT &PDIR
bic.b #BIT &PUT
; TODO: blue light
bis.b #BIT &PDIR
bic.b #BIT &PUT
; put zero on display
mov #DISP, r
add # r
mov.b @r &PUT
; TODO: initialize timer ;USED FOR THE GREEN LIGHT
mov # &TACCR
mov #CCEI, &TACCTLO
mov TASSELIDMC & TACTL
mov TASSELIDMC &TACTL
; TODO: initialize timer ; USED FOR THE BLUE LIGHT
mov # &TACCR
mov #OUTMOD &TACCTL
mov #TASSELIDMC &TACTL
; we'll definitely need interrupts enabled
eint
Lloop:
; execute forever
; TODO: blink red light
xor.b #BIT &PUT
mov # R
call #delayms
jmp Lloop
; DELAYMS FUNCTION
;
delayms:
mov
r r
# r
r
r
b
r
b
BUTTON:
; TODO: go back to previous mode
BUTTON:
; TODO: go forward to next mode
; debounce routine
and.b #BIT &PIN
jz b
push r
push r
mov # r
call #delayms
pop r
pop r
bic.b #BIT &PIFG
reti
TIMER:
; TODO: what should timer do
reti
UNEXPECTEDISR:
reti
; INTERRUPT VECTOR TABLE
section vectors", ax @progbits
word UNEXPECTEDISR ;xffe
word UNEXPECTEDISR ;xffe
word BUTTON ;xffePORTVECTOR
wOrd BUTTON ;xffePORTVECTOR
word UNEXPECTEDISR ;xffe
word UNEXPECTEDISR ;xffea ADCVECTOR
word UNEXPECTEDISR ;xffec USCIABOTXVECTOR
word UNEXPECTEDISR ;xffee USCIABRXVECTOR
word UNEXPECTEDISR ;xfffTIMERAVECTOR
word UNEXPECTEDISR ;xfffTIMERAVECTOR
word UNEXPECTEDISR ;xfffWDTVECTOR
word UNEXPECTEDISR ;xfffCOMPARATORAVECTOR
word UNEXPECTEDISR ;xfffTIMERAVECCTOR
word TIMER ;xfffa TIMERAVECTOR
word UNEXPECTEDISR ;xfffc NMIVECTOR
word MAIN ;xfffe RESETVECTOR
end
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
