Question: We want to use Timer 2 to log the time an INT 0 event occurs. When the INT 0 interrupt occurs we will write the

We want to use Timer2 to log the time an INT0 event occurs. When the INT0
interrupt occurs we will write the value in TMR2 to a circular buffer. In the following assume a
PIC24FJ64GA002 microcontroller operating with a 16 MHz instruction cycle clock, Fcy .
(a) Show the code needed to initialize amd enable Timer2 with a 1 ms period. Use the smallest
possible time increment. Timer2 should be assigned its natural priority.
(b) Show the definition and initialization of the 64 element circular buffer, buffer, as well has the
front and back pointers.
(c) Code an INT0 interrupt service routine (ISR) which will grab the value in TMR2 as quickly
as possible, place it in the circular buffer, and update the pointers.
(d) Briefly describe how this scheme differs from using the input capture peripheral to log the time
of an event on a pin.

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!