// ISR VECTOR
#if defined(__18CXX)
#if defined(HI_TECH_C)
void interrupt low_priority LowISR(void)
#else
#pragma interruptlow LowISR
void LowISR(void)
#endif
{
TickUpdate();
Timer2Interrupt(); // For DoIP purposes
}
/////////////////////////////////////
// ISR FUNCTION
/////////////////////////////////////
void Timer2Interrupt()
{
if (PIR1bits.TMR2IF == 1)
{
PIR1bits.TMR2IF=0;
boolReadADC = 1;
if (cnt8000 < 8000)
cnt8000++;
else
cnt8000 = 0;
}
}
void InitTimer2()
{
T2CON = 0b0100100; // Postscaler = 1:10, Prescaler = 1:1
PR2 = 124; // 125 counts including 0
T2CONbits.TMR2ON = 1;
}
void InitADC()
{
ADCON0 = 0b00000001;
ADCON1 = 0b00001110;
ADCON2 = 0b00010010;
DDRAbits.RA0 = 1;
}
void VoIP_Main() // is inside the Main funtion's while loop
{
if (boolReadADC==1)
{
boolReadADC = 0;
ReadADC();
}
}
void ReadADC()
{
ADCReadings[cnt160] = ADRESH;
ConvertADC(); // Start conversion
if (cnt160 < 159)
cnt160++;
else
cnt160 = 0;
}