Question: 3. (15 points) PIC C programming Complete the short function below by writing the appropriate line(s) of C code into each of the blank spaces.

 3. (15 points) PIC C programming Complete the short function below

3. (15 points) PIC C programming Complete the short function below by writing the appropriate line(s) of C code into each of the blank spaces. The purpose of each line is described in a comment to the right of the blank. This interrupt service routine detects both switch and timer interrupts and works with the analog to-digital converter (ADC) The ISR does the following: . On a timer interrupt, start an analog-to-digital conversion. On a switch interrupt, check if the ADC is done. If the ADC is done, assign the lowest four bits of the result to the LEDs, making sure to only change the lowest four bits of Port C while leaving the upper four bits the same Assume the LEDs are wired to the lowest four bits of Port C (as on the board used in HW 8) the ADC result is right-justified, and that "SWITCH" and DOWN are appropriately defined. void interrupt ISR (void) if( ) // SW1 was pressed delay ms (5) if (SMITCHDOWN) // Clear flag in software // Delay for debouncing // If switch still pressed if ( // check ?f ADC 13 a ne // If done, assign lowest 4 // result bits to LEDs, // making sure to only // change correct bits if (INTCONbits.TOIF) // Timer 0 interrupt // clear flag in software // Start ADC 3. (15 points) PIC C programming Complete the short function below by writing the appropriate line(s) of C code into each of the blank spaces. The purpose of each line is described in a comment to the right of the blank. This interrupt service routine detects both switch and timer interrupts and works with the analog to-digital converter (ADC) The ISR does the following: . On a timer interrupt, start an analog-to-digital conversion. On a switch interrupt, check if the ADC is done. If the ADC is done, assign the lowest four bits of the result to the LEDs, making sure to only change the lowest four bits of Port C while leaving the upper four bits the same Assume the LEDs are wired to the lowest four bits of Port C (as on the board used in HW 8) the ADC result is right-justified, and that "SWITCH" and DOWN are appropriately defined. void interrupt ISR (void) if( ) // SW1 was pressed delay ms (5) if (SMITCHDOWN) // Clear flag in software // Delay for debouncing // If switch still pressed if ( // check ?f ADC 13 a ne // If done, assign lowest 4 // result bits to LEDs, // making sure to only // change correct bits if (INTCONbits.TOIF) // Timer 0 interrupt // clear flag in software // Start ADC

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