Q1. Given the following setup code for Timer 2, write an Interrupt Service Routine (ISR) for Timer 3 that uses INV to toggle the LED light connected to Port A, RA5. The ISR should be called Timer3Interrupt. Timer 3 setup: Internal fPB clock is 40Mhz , pre-scalar 1:256
Q2. a) If TAD = 85 * 10-9 (85 ns) Seconds (Assume PBclk-Freq = 40 MHz , [2 Marks] So TPB = 1 PBclk − Freq ), Calculate the ADC’s value. Hint: TAD = 2 * (TPB * (ADCs + 1)) b) Write the following Setup code for the ADC with manual sampling and manual conversion.
Q3a.Write a program using an Interrupt Service Routine that does the following : Waits for a Single High Pulse of 250 ms on Pin OC3. When the High Pulse goes from High to low , it turns ON the LED at Port A, RA3 and the LED then stays on.
You will use the Output Compare OC1, Dual Compare mode with a Single High Pulse (OCM= 004). You will use Timer 3 for the OC with a pre-scale value of 256. You need to setup OC3RS and OC3R such that OC3RS – OC3R = 200 ms. We need to convert 200 ms into Timer Clock Cycles. We have Timer 3 with a fpb is 10 Mhz and a Precale of 1:64