Question
Consider the following code segment. Assume that processor clock in the active mode is set to 2,000,000 Hz. while(1) { int i; for(i = 2000;
Consider the following code segment. Assume that processor clock in the active mode is set to 2,000,000 Hz.
while(1) {
int i;
for(i = 2000; i>0; i--); // one loop iteration takes 5 clock cycles
P3OUT |= BIT5; // Set P3.5
for (i = 2000; i>0; i--); // Delay
P3OUT &= ~BIT5; // Clear P3.5
}
A. (5 points) What does the code segment do assuming that P3.5 is configured as a digital output. You may ignore delay needed to execute instructions in lines 1, 4 and 6.
B. (5 points) What will happen if you connect P3.5 to the buzzer?
C. (5 points) How would you implement functionality achieved by the code segment above using TimerB. Port P3.5 is multiplexed with the output signal from the capture and compare block 4 of TimerB. Give details. How would you initialize the system? What would you do in the main loop?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started