General

¡Bienvenido!

This community is for professionals and enthusiasts of our products and services. Share and discuss the best content and new marketing ideas, build your professional profile and become a better marketer together.

0

M-Duino 21+ TIMER3_COMPA_vect

Avatar
Kai Kriese

Hi, how can I use the ISR(TIMER3_COMPA_vect) from this code: https://www.industrialshields.com/blog/arduino-industrial-1/post/servo-motor-with-arduino-based-plc-104, in the void loop?

If I copy the ISR in the loop, the Arduino IDE shows me these error messages:


Arduino: 1.8.12 (Windows 10), Board: "M-Duino family, M-Duino 21+"


In file included from C:\Users\xt\AppData\Local\Arduino15\packages\industrialshields\hardware\avr\1.1.38\cores\industrialshields/Arduino.h:30:0,


from sketch\m-duino_test_2.ino.cpp:1:


C:\Users\xt\Documents\Arduino\m-duino_test_2\m-duino_test_2.ino: In function 'void loop()':


m-duino_test_2:25:3: error: expected unqualified-id before string constant


ISR(TIMER3_COMPA_vect) {


^


m-duino_test_2:25:26: error: a function-definition is not allowed here before '{' token


ISR(TIMER3_COMPA_vect) {


^

Avatar
Descartar
1 Respuesta
0
Mejor respuesta

Dear Kai,

As we can notice from the error messages, you are including the ISR function inside the loop function. This is not written correctly.

To solve the problem, please write the code like so:

ISR(TIMER3_COMPA_vect) {
...

}

void setup() {

attachInterrupt() (check https://www.arduino.cc/en/Reference/attachInterrupt for more information)

}

void loop() {

...

}

Avatar
Descartar