Go Down

Topic: Not able to initiate timer interrupt for Arduino UNO wifi rev2 (Read 148 times) previous topic - next topic

olivers1

Hi,

I am trying to set up a timer interrupt to run a certain function with a repetitive time intervall. I have read through the datasheet in order to set up a timer interrupt. But I am not able to make it work.http://ww1.microchip.com/downloads/en/DeviceDoc/40002016A.pdf


- Can somebody help me out?
- I am also not sure what name the interrupt vector must have in order to be run when the timer interrupt is active?

The code i have written so faar:

ISR(RTC_CNT_vect) {
  Serial.println("hello");
 
}


void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  FUSE.OSCCFG = (FUSE.OSCCFG & 0b11111100) | 0b1;               //16 MHz cpu frequency selected.
  CLKCTRL.MCLKCTRLA = (CLKCTRL.MCLKCTRLA & 0b11111100) | 0b1;   //32,768 kHz internal oscillator selected (OSCULP32K).
  if(RTC.STATUS = RTC.STATUS & 0b1 == 0) {                      //check that the CTRLABUSY flag in RTC.STATUS is cleared before writing to this register.
    RTC.CTRLA  = (RTC.CTRLA & 0b10000110) | 0b1111101;          //32768 as prescaler (0b11110000), corr enabled (0b100) and rtc enabled (0b1).
    Serial.println("test");
  }
}

void loop() {
  // put your main code here, to run repeatedly:

}


Go Up