timer interrupt

hi, i have some code that communicate over i2c with a sensor. Sometimes the sensor stop working and the code stay locked in the i2c function. Now i want use an interrupt timer, it has to be launched at least every seconds, and don't modify any prescaler etc.. because i need the timers for external library. it will look at a variable that is incremented every loop(), and if the variable is >0 all is fine, otherwise it will reset the sensor (turn it off and restart communications?) i've tried:

void setup(){
  TIMSK2 |= B00000100;
unsigned long time = micros();
void loop(){

ISR(TIMER2_OVF_vect) {

but nothing happen... help please?

It looks like you’re setting the OCIE2B bit (output compare), try setting TOIE2 (overflow, 0000001).

Also try using nmemonics

TIMSK2 |= (1<<TOIE2);

And “time” should be volatile if you ever start using it outside the ISR.