WinVistaSP2
Ardiuno-0019
ArduIMU V2 (flat) hardware
ArduIMU software Version 1.8.1 downloaded Oct 17, 2010 (today)
from http://code.google.com/p/ardu-imu/downloads/detail?name=ArduIMU_1_8_1.zip&can=2&q=
Everything works fine out of the box, including ArduIMUTest.exe V1.1.12, and in the Ardiuno serial monitor I can see the attitude data streaming by.
But when I add "pinMode( 9,OUTPUT);" to the setup() function and "analogWrite( 9,x)" to the loop() function of arduimu.pde, I get the following error:
core.a(wiring_analog.c.o):(.data.analog_reference+0x0): multiple definition of `analog_reference'
arduimu.cpp.o:(.data.analog_reference+0x0): first defined here
Any advice?
You need to be a member of diydrones to add comments!
Replies
Here's my work-around solution to arduimu.cpp's clobbering of Arduino's analog_reference.
In the header section of arduimu.pde add this line:
#include <pins_arduino.h>>
In the setup() procedure, add one or both of these two lines:
pinMode( 9,OUTPUT); // PWM0
pinMode(10,OUTPUT); // PWM1
Somewhere in the loop() procedure, add one or both of these two pairs of lines:
_SFR_BYTE(TCCR1A) |= _BV(COM1A1); // connect PWM0 to pin on timer 1, channel A
OCR1A = someInteger0to255; // set PWM0 duty
_SFR_BYTE(TCCR1A) |= _BV(COM1B1); // connect PWM1 to pin on timer 1, channel A
OCR1B = otherInteger0to255; // set PWM1 duty
This definitely works in the context that I listed in the base message here. It may not work in other contexts. The real solution would be for arduimu.cpp to import analog_reference rather than define its own.
The problem is that adruimu.cpp defines its own analog_reference rather than importing it from Arduino's wiring_analog.c. (Probably because somebody took a shortcut, which is now biting me.) For everybody else using ArduIMU this is OK because wiring_analog doesn't get used. But for anyone (like me) who calls analogWrite() the linker includes wiring_analog in order to implement analogWrite(), and thus it sees two definitions for analog_reference, which is a linker error, of course.
So to write to the PWM on pin 9 without calling analogWrite(), I tried copying and pasting some of the analogWrite source code into arduimu.pde. Looks like I killed my bootloader.
Now I'm studying how to re-flash the bootloader. Do I need to buy an AVRISP MkII? And if so, how would I connect it? The cable looks totally different than my Adafruit FTDI cable (TTL-232R 3.3V).