To generate this project using MPLAB Code Configurator (MCC), follow the next steps:
Timer1 Configuration:
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_GATE_ISR()
function needs to be updated to clear the Interrupt flag, read the counted
value, reset it afterward and re-enable the timer gate control for a new
acquisition. The following configuration is
used:void TMR1_GATE_ISR(void)
{
volatile uint16_t value = 0;
PIR5 &= ~(_PIR5_TMR1GIF_MASK);
value = TMR1_ReadTimer();
TMR1_WriteTimer(0);
T1GCON |= _T1GCON_T1GGO_MASK;
}