write a C function void waitForSignature ( unsingned cher pinNum , unsigned int
ID: 3840743 • Letter: W
Question
write a C function void waitForSignature ( unsingned cher pinNum , unsigned int min , unsigned int max ) where pinNum is a number from 0to 7 representing PD0 toPD7 . The function simply waits for a pulse of width in the range (min - max ) appar on pinNum (in port d ) for example . waitForSignature (5 , 20 , 90 ) means wait for a pulse of width in the range 20 - 90 millisecond to appear on pin PD5 .
a . use the timer to measure time . you do not need to setup the timer , Assume you have a function called startTimer() which initializes the time to zero . Also assume a function call stopTimer() which will return the number of CPU clocks ( Assume Clock speed is 16MHZ ) since startTimer () function was called
Explanation / Answer
In the given method printing the pin number when the desired time has elapsed.
In 7C the time in steps of 20 millisecond.example: 50 refers to one second.
waitForSignature ( unsingned cher pinNum , unsigned int min , unsigned int max )
{
While(1)
{
printf("timer to start");
starttimer((max-min)*50);
while(!endtimer())
{
delay(50);
}
printf(" done go to desired pin"+pinNum);
stopTimer();
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.