错误“'timer0_pin_port'"的原因是什么?和“'_vector_13'"? [英] What is the cause of the errors "'timer0_pin_port'" and "'_vector_13'"?

查看:36
本文介绍了错误“'timer0_pin_port'"的原因是什么?和“'_vector_13'"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#include "IRremote.h"

int receiver = 11;

IRrecv irReceiver(receiver);
decode_results results;

void setup() {
  // put your setup code here, to run once:
pinMode(buttonPinA, INPUT_PULLUP);
pinMode(buttonPinB, INPUT_PULLUP);
pinMode(buttonPinC, INPUT_PULLUP);
pinMode(buttonPinD, INPUT_PULLUP);
irReceiver.enableIRIn();
}

错误信息是:

Tone.cpp.o(来自插件的符号):在函数`timer0_pin_port'中:

(.text+0x0):`__vector_13'的多重定义

(.text+0x0): multiple definition of `__vector_13'

libraries\IRremote\IRremote.cpp.o (来自插件的符号):(.text+0x0):这里先定义

libraries\IRremote\IRremote.cpp.o (symbol from plugin):(.text+0x0): first defined here

c:/程序文件(x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe:禁用松弛:它不适用于多个定义

c:/program files (x86)/arduino/hardware/tools/avr/bin/../lib/gcc/avr/4.9.2/../../../../avr/bin/ld.exe: Disabling relaxation: it will not work with multiple definitions

collect2.exe:错误:ld 返回 1 个退出状态

collect2.exe: error: ld returned 1 exit status

exit status 1 板 Arduino/Genuino Mega 或 Mega 编译错误2560.

exit status 1 Error compiling for board Arduino/Genuino Mega or Mega 2560.

我最近发现tone"和IRremote"命令使用来自here的timer2.我不知道 timer2 到底是什么以及如何更改它.

I have recently discovered that "tone" and "IRremote" commands use timer2 from here. I am unaware of what timer2 really is and how to change it.

推荐答案

此错误是链接时间问题.两段库代码都声明了同名的东西(在本例中是一个计时器).

This error is a link-time issue. Two pieces of library code have both declared something with the same name (in this case it's a timer).

所以编译一切正常,现在链接器正在获取编译后的输出并将其包装成一个可执行文件.每次看到诸如 error: ld returned ... 之类的错误消息时,请知道这是链接问题,而不是语法问题.ld 是链接器(ld"是链接器程序的名称).

So the compilation was all OK, and now the linker is taking the compiled output and is wrapping it into an executable. Every time you see an error message like error: ld returned ..., know it's a link problem, and not a syntax issue. Anything ld is the linker ("ld" is the name of the linker program).

如此处所述:

https://forum.arduino.cc/index.php?topic=120955.msg2613823#msg2613823

编辑头文件 IRRemote.h 并更改库使用的定时器中断:

Edit the header file IRRemote.h and change which timer interrupt the library uses:

更改选择:

#define IR_USE_TIMER1   // tx = pin 9
// #define IR_USE_TIMER2     // tx = pin 3

例如:

// #define IR_USE_TIMER1   // tx = pin 9
#define IR_USE_TIMER2     // tx = pin 3

这篇关于错误“'timer0_pin_port'"的原因是什么?和“'_vector_13'"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆