Using PIT Interrupts to wake my ATTiny414 from sleep after 10 minutes

I have been trying to sleep my ATTiny414 for 10 minutes after which it will wake up and take a measure of a frequency using a frequency counter and go back to sleep. I tried implementing a for loop after wake up from interrupt to put the UCON to sleep till 4 seconds ( for testing purposes) but it seems to not wake up at all.

Following is the code i used for the PIT Interrupts

int PIT_Counter = 0;

void EnablePIT()
{
  RTC.PITINTCTRL = RTC_PI_bm;
  RTC.PITCTRLA = RTC_PERIOD_CYC32768_gc | RTC_PITEN_bm;
  SLPCTRL.CTRLA |= SLPCTRL_SMODE_PDOWN_gc;
  SLPCTRL.CTRLA |= SLPCTRL_SEN_bm;
  sleep_cpu();
}

// PIT Wake-Up Interrupt
ISR(RTC_PIT_vect)
{
  RTC.PITINTFLAGS = 1;
  if (PIT_Counter < 4)
  {
    PIT_Counter = PIT_Counter + 1;
    EnablePIT();
  }
  else
  {
    PIT_Counter = 0;
    RTC.PITINTCTRL = ~RTC_PI_bm;
    PORTA.DIRSET = PIN4_bm;                           // Make LED on PA4 an output
    PORTA.PIN4CTRL = PORT_INVEN_bm;                   // Invert output
    ADC0.CTRLA |= ~ADC_ENABLE_bm;
    Wire.begin();
    TCDSetup();
    RTCSetup();
    EvsysSetup();
  }
}

I call EnablePIT() to re-enable and sleep the UCON after I send a value to the I2C.
I'm reading the output using I2C and I dont recieve any values sadly. Any clues where I may be wrong?

You will probably find better ATtiny414 information in the general "AVR" forum:
https://www.avrfreaks.net

Thank you, I will try over there

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.