Question: 5 . Given PIC 2 4 H running at Fosc = 2 0 MHz with one digital input at RA 1 and one digital output

5. Given PIC24H running at Fosc =20MHz with one digital input at RA1 and one digital output at RB5.
(a) Write a function to configure RA1 as an input and generate a change notification interrupt (CN).
(b) Assume that a clock signal is connected to RA1. The following code decide whether the clock speed is
faster than 100 kHz or not. If the clock is faster than 100 kHz then set RB5 to 0, otherwise set RB5 to
1.
void _ISR _CNInterrupt(void){
CNcounter++;
_CNIF =0;
}
uint8 CNcounter;
void main (){
CNcounter =0;
configure();
T2CON=0x0000;
PR2=99;
_LATB5=0;
_T2IF=0;
T2CONbits.TON=1;
while(CNcounter <2)
if (_T2IF ==1){
_LATB5=1;
_T2IF =0;
break;
}
}
}
(c) Compute the percentage of CPU time taken by the above ISR.
Assume the following:
- Each statement consumes one instruction cycle.
- The RA1 input is a clock with a frequency equal to 100 kHz.

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!