Pages: [1]   Go Down
Author Topic: [solved] Need help porting OneWire.h to ATtiny84  (Read 4561 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:
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!
« Last Edit: February 12, 2012, 03:42:49 am by tht » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


Which OneWire library are you using?
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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…).
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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:
#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:
#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.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Works great, thank you!

Next problem already arrived…
Code:
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.
Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


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
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 10
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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  smiley-lol

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:

Code:
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)
« Last Edit: February 12, 2012, 04:29:25 am by tht » Logged

Global Moderator
Dallas
Offline Offline
Shannon Member
*****
Karma: 178
Posts: 12288
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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.
Logged

Pages: [1]   Go Up
Jump to: