Naguissa / uTimerLib

Arduino tiny and cross-device compatible timer library
https://www.foroelectro.net/electronica-digital-microcontroladores-f8/utimerlib-libreria-arduino-para-eventos-temporizad-t191.html
GNU Lesser General Public License v3.0
20 stars 9 forks source link

Error: no matching function for call to 'HardwareTimer::attachInterrupt #12

Closed AndKe closed 3 years ago

AndKe commented 3 years ago

Hi, I am using STM32 cores for STM32F109 version 1.9.0 with uTimerLib 1.6.0 my code in in essence:

include "uTimerLib.h"

TimerLib.setInterval_us(timerEvent, 50000); void timerEvent() { timeralarm = true; }

compilation fail with:


In file included from /home/andre/Arduino/projects/libraries/uTimerLib/src/uTimerLib.cpp:120:
/home/andre/Arduino/projects/libraries/uTimerLib/src/hardware/uTimerLib.STM32.cpp: In member function 'void uTimerLib::_attachInterrupt_us(long unsigned int)':
/home/andre/Arduino/projects/libraries/uTimerLib/src/hardware/uTimerLib.STM32.cpp:57:52: error: no matching function for call to 'HardwareTimer::attachInterrupt(int, void (&)(HardwareTimer*))'
   57 |     Timer3->attachInterrupt(1, uTimerLib::interrupt);
      |                                                    ^

......

In file included from /home/andre/Arduino/projects/libraries/uTimerLib/src/uTimerLib.cpp:120:
/home/andre/Arduino/projects/libraries/uTimerLib/src/hardware/uTimerLib.STM32.cpp: In member function 'void uTimerLib::_attachInterrupt_s(long unsigned int)':
/home/andre/Arduino/projects/libraries/uTimerLib/src/hardware/uTimerLib.STM32.cpp:98:52: error: no matching function for call to 'HardwareTimer::attachInterrupt(int, void (&)(HardwareTimer*))'
   98 |     Timer3->attachInterrupt(1, uTimerLib::interrupt);
      |                                                    ^

Any ideas why ?

Naguissa commented 3 years ago

STM32F109? I don't find its datasheet, any info or that model on Arduino boards selector. Maybe it's 103?

AndKe commented 3 years ago

Yes, my mistake STM32F103 is correct

On Mon, 6 Jul 2020 at 14:53, Naguissa notifications@github.com wrote:

STM32F109? I don't find its datasheet, any info or that model on Arduino boards selector. Maybe it's 103?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Naguissa/uTimerLib/issues/12#issuecomment-654215870, or unsubscribe https://github.com/notifications/unsubscribe-auth/AALGTKVD24PJODVWHPY3LYLR2HCLDANCNFSM4ORMJ7UQ .

AndKe commented 3 years ago

Additional information: this library/code worked fine half a year ago or so (older versions of STM32 core , this library, and maybe Arduino)

Naguissa commented 3 years ago

Additional information: this library/code worked fine half a year ago or so (older versions of STM32 core , this library, and maybe Arduino)

Yes, it worked: #9

Seems they have changed timers. I'll fix it asap.

Naguissa commented 3 years ago

I've just released version 1.6.1 trying to fix that issue.

There're some changes on compiling process and timer usages.

But I'm having trouble testing it, on Roger clark and ST's core, also on blue pill and Maple mini....

So please, comfirm me if all issues are solved....

Cheers!

AndKe commented 3 years ago

I tried 1.6.1 on BluePill with F103C8T6 - it compiles fine.

This, modified example:

/**
   uTimerLib example

   @author Naguissa
   @url https://www.github.com/Naguissa/uTimerLib
   @url https://www.foroelectro.net
*/

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

#ifndef LED_BUILTIN
// change to fit your needs
#define LED_BUILTIN PC13
#endif

volatile bool status = 0;

void timed_function() {
  status = !status;
}

void setup() {

  pinMode(LED_BUILTIN, OUTPUT);
  int x = 0;
  while (x < 5) {
    digitalWrite(LED_BUILTIN, status);
    delay(100);
    status = !status;
    x++;
  }

  TimerLib.setInterval_s(timed_function, 2);
}

void loop() {
  digitalWrite(LED_BUILTIN, status);
}

first I see rapid flashing as expected. (proving PC13 is the right pin)

Naguissa commented 3 years ago

Fixed and checked on 1.6.2 release.

If you have any problem check LED pin on examples.

AndKe commented 3 years ago

Ok, I tried the stock 1.6.2 's uTimerlib_setinterval_s_example_led, only modifying led to PC13 - did not work. So I tried the "serial" variation of the example - did not work... So I added one println to it like:

void setup() {
    Serial.begin(57600);
  Serial.println("eiudhuehhd !");
    TimerLib.setInterval_s(timed_function, 2);

And after each reset - my terminal sees "eiudh" then no more characters. To me it seems like the setInterval_s call crashes the STM somehow so that the string is never completed.

AndKe commented 3 years ago

@Naguissa please look into this - it still won't work with bluepill.

Naguissa commented 3 years ago

Finally I've sorted my environment. I had to reinstall STCore because something was (probably) corrupt, but also install stm32cubeprogrammer crap in order to use STLink....

Results:

At first none worked, but I don't know if it was corrupted STCore or something wrong with my microcontrollers. Once I reinstalled and Maple mini worked once, every test has been passed without problems.

AndKe commented 3 years ago

@Naguissa Sorry for botherting you so much while trying to pinpoint the issue here, I do not know what is it's cause, but I suspect many more can have the same issue - as is it not clearly visible in projects that use, but not fully depend on the timer.

I closed Arduino. removed: /tmp/arduino* /home/andre/Arduino/projects/libraries/uTimerLib /home/andre/.arduino15/packages/STM32

My compilation completesm but is not working - compiler output: https://gist.github.com/AndKe/ed9dd5ca9f9e9f0561a1e21c2a89197b

Arduino_Core_STM32 Board: Generic STMF1 Board Part : Bluepill F103C8 U(S)ART support: Enabled(generic Serial) USB Support: CDC(generic "serial" supersede U(S)ART" USB Speed: Low/Full Speed Optimize: Smallest (-Os default) C Runtime Library : newlib Nano(default) Upload Method: STM23CubeProgrammer(SWD) (ST_LINKV2)

My build settings:

  Arduino_Core_STM32
  Board: Generic STMF1
  Board Part : Bluepill F103C8
  U(S)ART support: Enabled(generic Serial)
  USB Support: CDC(generic "serial" supersede U(S)ART"
  USB Speed: Low/Full Speed
  Optimize: Smallest (-Os default)
  C Runtime Library : newlib Nano(default)
  Upload Method: STM23CubeProgrammer(SWD)  (ST_LINKV2)

Can you please provide me your compiler output, or think of what else could be the difference here ?

Naguissa commented 3 years ago

https://gist.github.com/Naguissa/486ca6395cdf1ee40f111b487e703f15

I have STM32duino, but it doesn't interfere with STCore

Naguissa commented 3 years ago

I've found few uncommited changes. Commited and created new release: https://github.com/Naguissa/uTimerLib/releases/tag/1.6.3

AndKe commented 3 years ago

I were midway in a desperate full backup/clean install to try to figure out how it could work for you, not me. Glad to see there was a perfectly logical explanation, 1.6.3 works again perfectly.

Thank you.