To generate this project using MPLAB Code Configurator (MCC), follow the next steps:
main.c
file. The
macros were created by the MCC and the user needs to remove the “//” so they
are no longer treated as
comments:
// Enable the Global Interrupts
INTERRUPT_GlobalInterruptEnable();
// Enable the Peripheral Interrupts
INTERRUPT_PeripheralInterruptEnable();
tmr1.c
file, the TMR1_ISR()
function
needs to be updated to stop the gate control because the button was not
released yet and it will generate an undesired interrupt when that will
happen. It also needs to clear the Interrupt flag, reset the counted value
and re-enable the timer gate control for a new acquisition. The following
function is
used:void TMR1_ISR(void)
T1GCON &= ~_T1GCON_T1GGO_MASK;
PIR4 &= ~_PIR4_TMR1IF_MASK;
PIR5 &= ~_PIR5_TMR1GIF_MASK;
TMR1_WriteTimer(0);
T1GCON |= _T1GCON_T1GGO_MASK;
if(TMR1_InterruptHandler)
{
TMR1_InterruptHandler();
}
}
tmr1.c
file, the TMR1_GATE_ISR()
function needs to be updated to clear the Interrupt flag, reset the counted
value and re-enable the timer gate control for a new acquisition. The
following function is
used:void TMR1_GATE_ISR(void)
{
PIR5 &= ~(_PIR5_TMR1GIF_MASK);
TMR1_WriteTimer(0);
T1GCON |= _T1GCON_T1GGO_MASK;
}