Naguissa/uTimerLib

ARDUINO_STM32 - setInterval_s not correctly trigged

mignon-ne opened this issue · 7 comments

I have try with Maple compatible board.
When call with any value, it trig on every 1 second.

As example:
void setup() {
Serial.begin(57600);
TimerLib.setInterval_s(timed_function, 2);
prevMillis = millis();
}

Will result in 1000

However, TimerLib.setInterval_us return correctly.
TimerLib.setInterval_us(timed_function, 2000000);
Will result in 2000

I see examples are not very correct, as you shouldn't use time-based functions inside an interrupt.

I will test this later, but, could you check this modified example result?

#include "Arduino.h"
#include "uTimerLib.h"

volatile unsigned long int prevMillis = 0;
volatile unsigned long int actMillis = 0;

void timed_function() {
	Serial.println(actMillis - prevMillis);
	prevMillis = actMillis;
}

void setup() {
	Serial.begin(57600);
	TimerLib.setInterval_s(timed_function, 2);
	prevMillis = millis();
}

void loop() {
  actMillis = millis();
}

OK, fixed.

There was a part missing when managing interrupts on STM32 for "seconds" functions.

Also, I enhanced examples with more correct coding.

It's not possible with this library. But I suggest to do a broker function and call it at Maximum Common Divissor.

Timers is a scarce resource, so you should preserve them. Also, Arduino functions and libraries are using some of them.

I try to use less common ones, so using even more timers will limit your options.

Thank you very much.

Not sure relate to an update or not, but seem the location is moved.
When compiled, it is completd and run successful.
However, I have warning. Possible my own issue,

Resetting USB to switch back to runtime mode
Invalid library found in C:\Users...\Documents\Arduino\libraries\uTimerLib: no headers files (.h) found in C:\Users...\Documents\Arduino\libraries\uTimerLib
Invalid library found in C:\Users...\Documents\Arduino\libraries\uTimerLib: no headers files (.h) found in C:\Users...\Documents\Arduino\libraries\uTimerLib

How did you installed/updated the library? You can do it via Library Manager on Arduino IDE.

You should check that location, seems to have any invalid copy there....

Solved, my own issue.

Found that your library name is "arduino_339753".
Probably from update, during open that folder "uTimerLib" and files.
Removed and re-install solved.
Thanks.