I2C and Timer0 module in PIC16F1519 (and PIC16F18325)
I am referring code of Thermometer Demonstration of Microchip.
I have uploaded here main.c and i2c.c file here for reference. I have understand how they have implemented I2C in i2c.c file and using it in function
unsigned int IR_temp_read(unsigned char command)
But in the same function they are using below loop and there I dont know why they have used Timer0 flag to check.
Timer0 flag with SSP1 flag for checking data received or not, then they reading buffer.
while((PIR1bits.SSP1IF == 0) || (INTCONbits.TMR0IF == 1));
if(INTCONbits.TMR0IF == 0)
TMR0 = 0;
INTCONbits.TMR0IF = 0;
Please help to understand this.
Timer0 is initialized as below. I don't know how & why they used Timer0 as below.
void Timer0_Init (void)
INTCON = 0x00;
TMR0 = 0;
OPTION_REG = 0x83;
I am thinking that they might have used Timer0 to figure out Time has not gone beyond limit for receiving data. If gone, they are reading buffer. So please help me to find purpose of checking Timer0 flag.
What if I not use Timer0, what will happen ? Because I just want to use I2C for data reception.
Also I want to migrate this code of PIC16F1519 to PIC16F18325. I have changed all the I2C code with proper syntax since PIC16F18325 have two MSSP. But I stuck migrating Timer0 because of above function.
Thanks in advance for help & Stay safe.