Go Down

Topic: [solved] Need help porting OneWire.h to ATtiny84 (Read 6 times) previous topic - next topic

tht

Feb 11, 2012, 10:30 pm Last Edit: Feb 12, 2012, 09:42 am by tht Reason: 1
Hi,

I just registered to this forum but I already know the Arduino platform, C and some hardware stuff. I'm working on a small project where I have to read one analog sensor and a 1wire device (DS18B20). The data has to be sent using a RFM12B module. Looks like my only problem is the OneWire library…

I'm using Arduino 1.0 on OS X and have installed the latest version of the arduino-tiny library from http://code.google.com/p/arduino-tiny/

When I try to compile the code I get these errors:
Code: [Select]
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp: In constructor 'OneWire::OneWire(uint8_t)':
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp:105: error: 'digitalPinToBitMask' was not declared in this scope
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp:106: error: 'digitalPinToPort' was not declared in this scope
Documents/Arduino_1.0/libraries/OneWire/OneWire.cpp:106: error: 'portInputRegister' was not declared in this scope


I'm a bit confused because all these functions are defined in Arduino_1.0/hardware/tiny/cores/tiny/pins_arduino.h. Actually these are not functions but preprocessor macros but why doesn't this work?

I'm planning to make some custom pcb's and don't like the idea to go to a ATmega only because of this 1wire library… Any ideas? I could provide some demo-code if needed.

Thanks!

Coding Badly


tht

I got version 2.1 from here:
http://www.pjrc.com/teensy/td_libs_OneWire.html

Good idea, I wasn't looking for another library (until now…).

Coding Badly


I suggest using Paul Stoffregen's library.  You can get it working by...

• Locate and open OneWire.h

• Locate this section of code towards the top...

Code: [Select]
#if ARDUINO >= 100
#include "Arduino.h"       // for delayMicroseconds, digitalPinToBitMask, etc
#else
#include "WProgram.h"      // for delayMicroseconds
#include "pins_arduino.h"  // for digitalPinToBitMask, etc
#endif


• Change it to this...

Code: [Select]
#if ARDUINO >= 100
#include "Arduino.h"       // for delayMicroseconds, digitalPinToBitMask, etc
#include "pins_arduino.h"  // for digitalPinToBitMask, etc
#else
#include "WProgram.h"      // for delayMicroseconds
#include "pins_arduino.h"  // for digitalPinToBitMask, etc
#endif


• Save and close OneWire.h

• It is not necessary to restart the Arduino IDE


To be quite clear about the matter: This is not a problem with the OneWire library but rather a deficiency in the Tiny Core.  Essentially, Paul has made OneWire compatible with Arduino 1.0 while the Tiny Core is only partial compatible.

tht

Works great, thank you!

Next problem already arrived…
Code: [Select]
hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x0): relocation truncated to fit: R_AVR_13_PCREL against symbol `main' defined in .text.main section in core.a(main.cpp.o)
hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/../../../../avr/lib/avr25/crttn84.o:(.init9+0x2): relocation truncated to fit: R_AVR_13_PCREL against symbol `exit' defined in .fini9 section in hardware/tools/avr/bin/../lib/gcc/avr/4.3.2/avr25/libgcc.a(_exit.o)


The problem goes away when I remove all references to OneWire OR rfm12b. Looks like some kind of resource problem. It's not the sketch-size, it has to be something else… I'll try to restructure my code.

Coding Badly


You are welcome.

Quote
R_AVR_13_PCREL ... It's not the sketch-size...


Actually, in a complicated way, the symptom is triggered by sketch size.  I can also help with that problem...

http://arduino.cc/forum/index.php/topic,51984.msg371259.html#msg371259
http://arduino.cc/forum/index.php/topic,51984.msg371307.html#msg371307

tht

#6
Feb 12, 2012, 10:27 am Last Edit: Feb 12, 2012, 10:29 am by tht Reason: 1
I actually did hope for one more reply from you :-)

It's not the first time I run into a problem with the Arduino 1.0 toolchain. It's a 1.0 - there have to be problems  XD

Thanks for the links, google actually wasn't really useful on this problem. Too bad I can't use your install instructions as I'm running Arduino on OS X, not Windows. WinAVR sounds a little bit like a Windows application…

I just found a nice OS X package with all the required files. Here's how to install it:


  • Download package from http://www.obdev.at/products/crosspack/index-en.html

  • Install

  • Close Arduino IDE (if not yet done)

  • Open a terminal and enter these commands:


Code: [Select]
cd /Applications/Arduino.app/Contents/Resources/Java/hardware/tools
mv avr avr-old
ln -s /usr/local/CrossPack-AVR avr


For me it works perfect (until now…)
Done compiling.
Binary sketch size: 4966 bytes (of a 8192 byte maximum)

Coding Badly

I actually did hope for one more reply from you :-)


This will probably be the last for a while.  It's about :smiley-sleep:...

Quote
Thanks for the links, google actually wasn't really useful on this problem.


You aren't kidding!

Quote
Too bad I can't use your install instructions as I'm running Arduino on OS X, not Windows.


Sorry about that.  I missed the "OS X" in your original post.  Yes, the instructions are for Windows.

Quote
I just found a nice OS X package with all the required files. Here's how to install it:


Thank you for posting the follow-up with instructions.

Go Up