Arduino Forum

Products => Arduino WiFi Rev2 => Topic started by: olivers1 on Mar 25, 2019, 09:29 am

Title: Not able to initiate timer interrupt for Arduino UNO wifi rev2
Post by: olivers1 on Mar 25, 2019, 09:29 am
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 (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:

}

Title: Re: Not able to initiate timer interrupt for Arduino UNO wifi rev2
Post by: PickyBiker on May 22, 2019, 01:20 am
This is an old post but I can offer a couple suggestions.
First, it is not good practice to put a print statement inside an ISR. A better option is to set a flag and then initiate the print in the loop if the flag is set.

Another suggestion is to check the following post to see if your Rev2 is assembled wrong.
https://github.com/arduino/ArduinoCore-megaavr/issues/27 (https://github.com/arduino/ArduinoCore-megaavr/issues/27)

Lastly, my board had the manufacturing defect described above. I returned it and am waiting for the replacement to arrive. I should get it in a few days and will let you know if your code works on that board.
Title: Re: Not able to initiate timer interrupt for Arduino UNO wifi rev2
Post by: PickyBiker on May 25, 2019, 02:09 am
Unfortunately the new Rev2 arrived with the same problem so I can't try to duplicate this issue.