Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

5) (25 points) Comment each line of the following code, assuming it runs on the

ID: 2249482 • Letter: 5

Question

5) (25 points) Comment each line of the following code, assuming it runs on the MSP430 board you use in the lab. Then explain what the code is doing overall. Use a diagram if necessary bis.b #BITO, &PIDIR; ; bis.b #BIT2+81T6, &PIDIR; bis.b #BIT2+81T6,&P1SEL; bis.b #BIT7, &PIIES; P1IntErn bis.b #BIT7,6P11E ; eint SetupTA ; ; bic.b #0xff,EP11FG ; mov #TAS SEL 1+1D1+1D0+TACLR,&TACTL; ; mov #PHMPeriod, &TACCRO; Wait4Int Int mp Wait4Int OR this code: PortlISR: inc.b r5 bic.b #0xff,EP11FG bic.b #0xff,EPIIE bic.b #~ (BITO), r5 ne DC2 jmp ToggleLED ToggleLED xor.b #BITO, &P1OUT; bis.b #BIT7,6P1IE eint

Explanation / Answer


bis.b #BIT0,&P1DIR; //Set the P1.0 as output for the LED.
bis.b #BIT0,&P1OUT; //Ensure the LED is off to start with.
bis.b #BIT2+BIT6,&P1DIR; //
bis.b # BIT2+BIT6,&P1SEL;
bis.b #BIT7,&P1IES; //enable the interrupt on bit 7
P1IntEn bic.b #0xff,&P1IFG;//
bis.b #BIT7,&P1IE;//disable the flag
eint;
SetupTA mov #TASSEL1+ID1+ID0+TACLR,&TACTL;//select the ID & ID1 & clear the TARadd bit 2 and bit6 Make them output
mov #OUTMOD1 ,&TACCTL1;
mov #PWMPeriod,&TACCR0;
mov #PWMDC1,&TACCR1;
bis #MC1 + MC0,TACTL;turn off timer TA0
Wait4Int jmp Wait4Int ;
Or this code:
_Port1ISR_:
Inc.b r5; //increment the r5//
bic.b #0xff,&P1IFG; //enable the interrupt flag
bic.b #0xff,&P1IE; //enable the inturrupt.
bic.b #~(BIT0),r5; //mov r5 and negate it
cmp.b #BIT0, r5 ; //compare the bit 0 and r5
jne DC2 ; //jump to the D2
mov #PWMDC1,&TACCR1 ;//PWM timer enable
jmp ToggleLED; //toggle the LED in loop
DC2 mov #PWMDC2,&TACCR1 ;//pwm timer
ToggleLED xor.b #BIT0,&P1OUT; //toggle the LED at P1.0
Bis.b #BIT7,&P1IE ; //Disable the interrupt on P1.7
eint ;
reti; //return from interrupt

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote