Question: Consider the following code segment that utilizes the watchdog timer in the interval mode with a period set in line 4 of the code. 1

Consider the following code segment that utilizes the watchdog timer in the interval mode with a period set in line 4 of the code.
1. #include
2. void main(void){
3.int p =0;
4.WDTCTL = WDT_MDLY_8; // check the meaning of this constant in the include file
5.P2DIR |= BIT2; // Set P2.2 to output direction
6.P2OUT &= ~BIT2; //
7.for (;;){
8.if ((IFG1 & WDTIFG)==1){
9.p++;
10.IFG1 &= ~WDTIFG;
11.if (p ==10) P2OUT ^= BIT2;
12.if (p ==14){ P2OUT ^= BIT2; p=0;}
13.}
14.}
15.}
A.(5 points) Describe this code segment detailing the functionality of the watchdog timer and any outputs that it may effect. What does the code in line 8 do?

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 Programming Questions!