Problem with IR Remote Control

Generic boards that are not Maple or Maple mini clones, and don't contain the additional USB reset hardware
Post Reply
User avatar
robert94
Posts: 7
Joined: Sun Jul 03, 2016 11:31 pm
Location: Vietnam

Problem with IR Remote Control

Post by robert94 » Mon Nov 28, 2016 10:03 am

Has anyone worked with IR Remote Control??? :?:
I have a problem with it. :(

Code: Select all

#include <IRremote.h>

int RECV_PIN = PA0;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
  delay(100);
}
problem: C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-master\IRremote.cpp:123:5: error: expected constructor, destructor, or type conversion before '(' token

ISR (TIMER_INTR_NAME)

^


someone please help me!!! :cry:

User avatar
zoomx
Posts: 523
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Problem with IR Remote Control

Post by zoomx » Mon Nov 28, 2016 5:44 pm

Unfortunately I never used IRremote with an STM32. I believe that this library uses timers so you have to adapt it to STM32 architecture.

User avatar
RogerClark
Posts: 7146
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Problem with IR Remote Control

Post by RogerClark » Mon Nov 28, 2016 10:39 pm

Guessing based on the file names in the output you posted, I think the library you are using is AVR only.

https://github.com/z3t0/Arduino-IRremote


Well, its supposed to work on Teensy as well, so Paul has probably added some Teensy specific stuff into it as well, but it doesnt support any Arduino ARM based boards.

Looking in the code for the word Teensy I can see there are some #ifdefs for stuff like __MK20DX128__ which I think is where the Teensy specific changes have been incorporated.

So you would need to go though the library and port it to ARM in general and STM32 in specific by adding in some more ifdefs and changing whatever is necessary

Or find a IR library that already works on ARM (e.g. Arduino Due or Zero) and modify that version to work with STM32

User avatar
robert94
Posts: 7
Joined: Sun Jul 03, 2016 11:31 pm
Location: Vietnam

Re: Problem with IR Remote Control

Post by robert94 » Fri Dec 02, 2016 8:54 am

RogerClark wrote:find a IR library that already works on ARM (e.g. Arduino Due or Zero) and modify that version to work with STM32
so i find library work with Arduino Due: https://github.com/enternoescape/Arduino-IRremote-Due
but still problem:

Code: Select all

#include <IRremote2.h>

int RECV_PIN = 11;

IRrecv irrecv(RECV_PIN);

decode_results results;

void setup()
{
  Serial.begin(9600);
  irrecv.enableIRIn(); // Start the receiver
}

void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value, HEX);
    irrecv.resume(); // Receive the next value
  }
}
problem is:

Code: Select all

Arduino: 1.6.13 (Windows 7), Board: "Generic STM32F103C series, STM32F103C8 (20k RAM. 64k Flash), Serial"

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp: In member function 'void IRsend::mark(int)':

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:262:31: error: 'TCCR2A' was not declared in this scope

 #define TIMER_ENABLE_PWM     (TCCR2A |= _BV(COM2B1))

                               ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:283:3: note: in expansion of macro 'TIMER_ENABLE_PWM'

   TIMER_ENABLE_PWM; // Enable pin 3 PWM output

   ^

In file included from C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/Arduino.h:30:0,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.h:14,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:19:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:262:45: error: 'COM2B1' was not declared in this scope

 #define TIMER_ENABLE_PWM     (TCCR2A |= _BV(COM2B1))

                                             ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:283:3: note: in expansion of macro 'TIMER_ENABLE_PWM'

   TIMER_ENABLE_PWM; // Enable pin 3 PWM output

   ^

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp: In member function 'void IRsend::space(int)':

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:263:31: error: 'TCCR2A' was not declared in this scope

 #define TIMER_DISABLE_PWM    (TCCR2A &= ~(_BV(COM2B1)))

                               ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:291:3: note: in expansion of macro 'TIMER_DISABLE_PWM'

   TIMER_DISABLE_PWM; // Disable pin 3 PWM output

   ^

In file included from C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/Arduino.h:30:0,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.h:14,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:19:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:263:47: error: 'COM2B1' was not declared in this scope

 #define TIMER_DISABLE_PWM    (TCCR2A &= ~(_BV(COM2B1)))

                                               ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:291:3: note: in expansion of macro 'TIMER_DISABLE_PWM'

   TIMER_DISABLE_PWM; // Disable pin 3 PWM output

   ^

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp: In member function 'void IRsend::enableIROut(int)':

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:265:31: error: 'TIMSK2' was not declared in this scope

 #define TIMER_DISABLE_INTR   (TIMSK2 = 0)

                               ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:312:3: note: in expansion of macro 'TIMER_DISABLE_INTR'

   TIMER_DISABLE_INTR; //Timer2 Overflow Interrupt

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:269:3: error: 'TCCR2A' was not declared in this scope

   TCCR2A = _BV(WGM20); \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:324:3: note: in expansion of macro 'TIMER_CONFIG_KHZ'

   TIMER_CONFIG_KHZ(khz);

   ^

In file included from C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/Arduino.h:30:0,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.h:14,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:19:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:269:16: error: 'WGM20' was not declared in this scope

   TCCR2A = _BV(WGM20); \

                ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:324:3: note: in expansion of macro 'TIMER_CONFIG_KHZ'

   TIMER_CONFIG_KHZ(khz);

   ^

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:270:3: error: 'TCCR2B' was not declared in this scope

   TCCR2B = _BV(WGM22) | _BV(CS20); \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:324:3: note: in expansion of macro 'TIMER_CONFIG_KHZ'

   TIMER_CONFIG_KHZ(khz);

   ^

In file included from C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/Arduino.h:30:0,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.h:14,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:19:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:270:16: error: 'WGM22' was not declared in this scope

   TCCR2B = _BV(WGM22) | _BV(CS20); \

                ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:324:3: note: in expansion of macro 'TIMER_CONFIG_KHZ'

   TIMER_CONFIG_KHZ(khz);

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:270:29: error: 'CS20' was not declared in this scope

   TCCR2B = _BV(WGM22) | _BV(CS20); \

                             ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:324:3: note: in expansion of macro 'TIMER_CONFIG_KHZ'

   TIMER_CONFIG_KHZ(khz);

   ^

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:271:3: error: 'OCR2A' was not declared in this scope

   OCR2A = pwmval; \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:324:3: note: in expansion of macro 'TIMER_CONFIG_KHZ'

   TIMER_CONFIG_KHZ(khz);

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:272:3: error: 'OCR2B' was not declared in this scope

   OCR2B = pwmval / 3; \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:324:3: note: in expansion of macro 'TIMER_CONFIG_KHZ'

   TIMER_CONFIG_KHZ(khz);

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp: In member function 'void IRrecv::enableIRIn()':

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:341:9: error: 'cli' was not declared in this scope

     cli();

         ^

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:284:3: error: 'TCCR2A' was not declared in this scope

   TCCR2A = _BV(WGM21); \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:347:3: note: in expansion of macro 'TIMER_CONFIG_NORMAL'

   TIMER_CONFIG_NORMAL();

   ^

In file included from C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/Arduino.h:30:0,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.h:14,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:19:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:284:16: error: 'WGM21' was not declared in this scope

   TCCR2A = _BV(WGM21); \

                ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:347:3: note: in expansion of macro 'TIMER_CONFIG_NORMAL'

   TIMER_CONFIG_NORMAL();

   ^

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:285:3: error: 'TCCR2B' was not declared in this scope

   TCCR2B = _BV(CS21); \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:347:3: note: in expansion of macro 'TIMER_CONFIG_NORMAL'

   TIMER_CONFIG_NORMAL();

   ^

In file included from C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/Arduino.h:30:0,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.h:14,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:19:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:285:16: error: 'CS21' was not declared in this scope

   TCCR2B = _BV(CS21); \

                ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:347:3: note: in expansion of macro 'TIMER_CONFIG_NORMAL'

   TIMER_CONFIG_NORMAL();

   ^

In file included from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:20:0:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:286:3: error: 'OCR2A' was not declared in this scope

   OCR2A = TIMER_COUNT_TOP / 8; \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:347:3: note: in expansion of macro 'TIMER_CONFIG_NORMAL'

   TIMER_CONFIG_NORMAL();

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:287:3: error: 'TCNT2' was not declared in this scope

   TCNT2 = 0; \

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:347:3: note: in expansion of macro 'TIMER_CONFIG_NORMAL'

   TIMER_CONFIG_NORMAL();

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:264:31: error: 'TIMSK2' was not declared in this scope

 #define TIMER_ENABLE_INTR    (TIMSK2 = _BV(OCIE2A))

                               ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:350:3: note: in expansion of macro 'TIMER_ENABLE_INTR'

   TIMER_ENABLE_INTR;

   ^

In file included from C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/Arduino.h:30:0,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.h:14,

                 from C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:19:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremoteInt2.h:264:44: error: 'OCIE2A' was not declared in this scope

 #define TIMER_ENABLE_INTR    (TIMSK2 = _BV(OCIE2A))

                                            ^

C:\Users\Robert\Documents\Arduino\hardware\Arduino_STM32-master\STM32F1\cores\maple/wirish.h:99:25: note: in definition of macro '_BV'

 #define _BV(bit) (1 << (bit))

                         ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:350:3: note: in expansion of macro 'TIMER_ENABLE_INTR'

   TIMER_ENABLE_INTR;

   ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:355:7: error: 'sei' was not declared in this scope

   sei();  // enable interrupts

       ^

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp: At global scope:

C:\Users\Robert\Documents\Arduino\libraries\Arduino-IRremote-Due-master\IRremote2.cpp:384:4: error: expected constructor, destructor, or type conversion before '(' token

 ISR(TIMER_INTR_NAME)

    ^

exit status 1
Error compiling for board Generic STM32F103C series.

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.
so what i have to do???
help me RogerClark :cry:

User avatar
zoomx
Posts: 523
Joined: Mon Apr 27, 2015 2:28 pm
Location: Mt.Etna, Italy

Re: Problem with IR Remote Control

Post by zoomx » Mon Dec 05, 2016 5:33 pm

Start from here
http://www.stm32duino.com/viewtopic.php ... =10#p12597
and go on.
It is not a solution, unfortunately, just some links.

I believe that maybe the solution found for tone can be used here.

Edit: some other links
https://www.youtube.com/watch?v=Ow5NHWXY4D0 and code here https://vk.com/akoe_ru?w=wall-51756903_860%2Fall
for STMf103x

Application note AN3174 by ST
http://www.st.com/content/ccc/resource/ ... 267896.pdf

These for F4 family
https://github.com/MatejGomboc/IRremote-STM32
http://www.playembedded.org/blog/it/201 ... e-chibios/ This is in italian.
http://www.playembedded.org/blog/en/201 ... g-chibios/ the same in english


If you want to use cube-mx
http://www.st.com/content/st_com/en/pro ... emote.html

41300895
Posts: 28
Joined: Tue Oct 25, 2016 12:19 pm

Re: Problem with IR Remote Control

Post by 41300895 » Wed Feb 01, 2017 7:32 am

Does anyone has the IR remote arduino library compatible with stm32f103?
If yes, please share, thanks alot

User avatar
Dimdim
Posts: 8
Joined: Mon May 09, 2016 10:34 am
Location: Athens, Greece
Contact:

Re: Problem with IR Remote Control

Post by Dimdim » Sat Mar 04, 2017 6:36 pm

Check out the IR code section of HiFiDuino's code: https://hifiduino.wordpress.com/code/

It works just fine on the STM32duino with any remote that uses the NEC protocol.

User avatar
RogerClark
Posts: 7146
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: Problem with IR Remote Control

Post by RogerClark » Sat Mar 04, 2017 8:49 pm

Dimdim wrote:Check out the IR code section of HiFiDuino's code: https://hifiduino.wordpress.com/code/

It works just fine on the STM32duino with any remote that uses the NEC protocol.

Thanks for posting. I recall a few people have been building IR projects recently.

User avatar
rexnanet
Posts: 205
Joined: Wed Mar 16, 2016 10:34 am

Re: Problem with IR Remote Control

Post by rexnanet » Tue Apr 11, 2017 9:49 am

I found one that seems to be working ok.

https://github.com/karawin/irmp-master

https://www.youtube.com/watch?v=R5umRl1Z8jc

Haven't tested it but on the video it's working on the BluePill :)

EDIT: The author already announced it here : http://www.stm32duino.com/viewtopic.php ... e&start=30

Post Reply