Arduino编译时出现的“multiple definition of错误”
代码功能是通过定时器/计数器0输出频率为490HZ的PWM波形代码如下
void setup()
{
DDRD |= 0x40; // PD6(OC0A)输出
//TCCR0A = 0x81; // 相位调整PWM模式,正向控制OC0A
TCCR0A = ( (1 << COM0A1) | (1 << WGM00) );
//TCCR0B = 0x02;//分频系数 = 8,
TCCR0B |= (1 << CS01);
TIMSK0 = 0x01; // T/C0溢出中断允许
TCNT0 = 0; // 初始化T/C0计数值
OCR0A = 64;
sei(); // 使能全局中断
pos = 0;
v = 16;
Serial.begin(9600);
}
void loop()
{
delay(1000);
}
ISR(TIMER0_OVF_vect)
{
pos += v; // 新样点指针
if (pos > 127)
pos -= 128; // 样点指针调整
OCR0A = auc_SinParam; // 取样点指针到比较匹配寄存器
Serial.print("pos = ");
Serial.println(pos);
}
编译后提示错误为:
core.a(wiring.c.o)* : : In function `__vector_16':
wiring.c : multiple definition of `__vector_16'
Timer_Counter0.cpp.o : :C:\Users\jdl\AppData\Local\VMicro\Arduino\Builds\Timer_Counter0\uno\Timer_Counter0.cpp:52: first defined here
Error creating .elf
这个问题怎么解决??求指教
预定义数组为const unsigned char auc_SinParam = {
64,67,70,73,76,79,82,85,88,91,94,96,99,102,104,106,109,111,113,115,117,118,120,121,
123,124,125,126,126,127,127,127,127,127,127,127,126,126,125,124,123,121,120,118,
117,115,113,111,109,106,104,102,99,96,94,91,88,85,82,79,76,73,70,67,64,60,57,54,51,48,
45,42,39,36,33,31,28,25,23,21,18,16,14,12,10,9,7,6,4,3,2,1,1,0,0,0,0,0,0,0,1,1,2,3,4,6,
7,9,10,12,14,16,18,21,23,25,28,31,33,36,39,42,45,48,51,54,57,60};
volatile unsigned char v;
volatile unsigned char pos; 问题解决了,原来是项目名字出现了问题
页:
[1]