RobotDynOfficial / RBDDimmer

The following library is used for work with dimmer, it gives ability to control large ammoun of dimmer. This lib uses with Leonardo, Mega, UNO, ESP8266, ESP32, Arduino M0, Arduino Zero, Arduino Due, STM32.
236 stars 111 forks source link

Library Interrupts Conflict #62

Open siteswapjuggler opened 1 year ago

siteswapjuggler commented 1 year ago

As far as I understand this library only use interrupt on pin 2, but the declaration of it is totally blocking other interrupt use tested on Uno and Micro.

Whatever the code is, the inclusion of this line attachInterrupt(digitalPinToInterrupt(3), ISR_routine, FALLING); give the following error :

WInterrupts.c.o (symbol from plugin): In function attachInterrupt': (.text+0x0): multiple definition of__vector_7' libraries/RBDDimmer/avr/RBDmcuAVR.cpp.o (symbol from plugin):(.text+0x0): first defined here

The vector number change if you use pin other than 3 on Arduino Micro.

siteswapjuggler commented 1 year ago

Ok some investigation later :

I will try some fixes but I will not have so much time to work on it correctly. This error could be common with other open issues so I hope it will help someone to correct it at one point :)

siteswapjuggler commented 1 year ago

Replacing content of ext_int_init by attachInterrupt(INTx,ISR_RBD,RISING); should do the trick. You will also have to declare ISR function befor ext_int_init and change ISR name by ISR_RBD.

blackbird257 commented 1 year ago

Hi! , thank you for the research of the library issue. I have same issue with the interruptions (I use another device on port D3). I'm trying to follow your advices, but I don't exactly know how to "declare ISR function before ext_int_init" - I just copied it before ext_int_init and renamed it to ISR_RBD. I get this error: /mnt/create-efs/webide/16/d4/16d4ee6b75059aa8801ddf6d27b06fde:lubos257/libraries_v2/RBDdimmer/src/avr/RBDmcuAVR.cpp:80:8: error: expected constructor, destructor, or type conversion before '(' token

ISR_RBD(INT_vect)

^

/mnt/create-efs/webide/16/d4/16d4ee6b75059aa8801ddf6d27b06fde:lubos257/libraries_v2/RBDdimmer/src/avr/RBDmcuAVR.cpp: In member function 'void dimmerLamp::ext_int_init()':

/mnt/create-efs/webide/16/d4/16d4ee6b75059aa8801ddf6d27b06fde:lubos257/libraries_v2/RBDdimmer/src/avr/RBDmcuAVR.cpp:92:23: error: 'ISR_RBD' was not declared in this scope

attachInterrupt(INTx,ISR_RBD,RISING);

Could you be more specific with "declare ISR function before ext_int_init" ,

  1. question, down in the code of ccp file is also anothre ISR function: ISR (TIMER_COMPA_VECTOR(DIMMER_TIMER)) , should I rename also that one? Sorry for stupid questions, I'm beginner with programming.
siteswapjuggler commented 1 year ago

Well by replacing the normal content of ext_int_init activate the function which implicitely link to

ISR(INT_vect) { for (int i = 0; i < current_dim; i++ ) if (dimState[i] == ON) { zeroCross[i] = 1; } }

By changing it to attachInterrupt(INTx,ISR_RBD,RISING); the link become explicit so you can replace the previous function by

ISR_RBD() { for (int i = 0; i < current_dim; i++ ) if (dimState[i] == ON) { zeroCross[i] = 1; } }

But then you need to declare it (move it) befor the declaration of ext_int_init ;)

Taprik commented 1 month ago

I have conflict with the RFM69 library with the same rrors WInterrupts.c.o (symbol from plugin): In functionattachInterrupt': (.text+0x0): multiple definition of __vector_7' I try your solution. It compiles but does not work. Still investigating ...

siteswapjuggler commented 1 month ago

Sorry it didn't work for you I was consulting for a client at the time, and do not have access to the project anymore to help you out. By the way my issue lack of descritption as I didn't even mention sur mcu and ide I was using... I hope you will find a solution.

Taprik commented 1 month ago

Thank you siteswapjuggler, I change attachInterrupt(INTx,ISR_RBD,RISING); to attachInterrupt(digitalPinToInterrupt(7),ISR_RBD,RISING); and it works the INTx defined in the header was not the correct one for my leonardo

siteswapjuggler commented 1 month ago

Well done thanks for sharing this solution :)