Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« on: January 26, 2011, 10:46:42 am » |
I like this new place. It's like moving into a new office! Just to say that I made a Playground article that provides the libs for I2C (master and slave) on the ATtiny85. It's here . . . http://www.arduino.cc/playground/Code/USIi2cHope some of you find it useful.
|
|
|
|
« Last Edit: January 26, 2011, 05:48:37 pm by BroHogan »
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Humboldt, CA
Offline
Full Member
Karma: 1
Posts: 220
Arduino BBB
|
 |
« Reply #1 on: January 29, 2011, 11:31:12 am » |
First off, thank you for writing this!
I gave it a whirl talking (or not, heh) to a AD5171 digital cap, I didn't get any output from pin5 or pin7 on the attiny, though I discovered when i was hooking it up that the closest to 4.7k resistors I had was 3.9k.
I'm going to spend some more time with it later on today hopefully, I'd be very, very pleased if I can get it to work as I was going to have to work out a way to bitbang it, which is rather over my head!
|
|
|
|
|
Logged
|
|
|
|
|
Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« Reply #2 on: January 29, 2011, 01:26:04 pm » |
I think 3.9K is close enough. (They are pull ups right?) So I'll assume . . . - your using the I2C master lib (TinyWireM) - it compiles and loads to the ATtiny fine - you have an LED on one of the other pins showing the sketch started - you put a scope on pin 5 (SDA) and pin 7 (SCL) and saw nothing
Humph, as you can see in the examples that come with the lib, as a master, I had it talking to an I2C temp sensor, RTC and a GPIO. The AD5171 looks like a straight forward chip to interface to.
What ATtiny core files are you using? I've only been using those from "high-low tech", and loading with the ArduinoISP or the USBtinyISP.
|
|
|
|
« Last Edit: January 29, 2011, 04:29:02 pm by BroHogan »
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Humboldt, CA
Offline
Full Member
Karma: 1
Posts: 220
Arduino BBB
|
 |
« Reply #3 on: January 30, 2011, 03:48:10 pm » |
I haven't done the scope yet, I'm going to take it to work on monday and do that. Got some 4.7k resistors for good measure. The attiny core files are one generation old now, I need to update. That might be the problem right there.
I'll update the core files and check it out on the scope and post back after that.
|
|
|
|
|
Logged
|
|
|
|
|
Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« Reply #4 on: January 30, 2011, 04:19:06 pm » |
Bob, Could confirm my assumptions - i.e. - your using the I2C master lib (TinyWireM) - YES ? - it compiles and loads to the ATtiny fine - YES ? - you have an LED on one of the other pins showing the sketch started - "NO BUT GOOD IDEA . . . YES IT DOES" ? - you put a scope on pin 5 (SDA) and pin 7 (SCL) and saw nothing - NO, BUT I KNOW I'M NOT GETTING OUTPUT BECAUSE . . .
That would help me help you. What ATtiny core files are you using? I've only been using those from "high-low tech", and loading with the ArduinoISP or the USBtinyISP.
I'm now guessing you are using the core files Coding Badly is involved with. I haven't tested with those. Try the cores from here http://hlt.media.mit.edu/wiki/pmwiki.php?n=Main.ArduinoATtiny4585You can change boards.txt if your using a programmer other than ArduinoISP. For example: attiny852.name=ATtiny85 (Load w/ USBtinyISP) attiny852.upload.using=arduino:usbtinyisp attiny852.upload.maximum_size=8192 attiny852.build.mcu=attiny85 attiny852.build.f_cpu=1000000L attiny852.build.core=attiny45_85 (What programmer are you using?) The "hlt" core works fine and it's simpler in some ways - a lot less going on in boards.txt. If you don't like that core for some reason, I still suggest you try it first - you can always go back to the other after you see everything working.
|
|
|
|
« Last Edit: January 30, 2011, 07:31:53 pm by BroHogan »
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« Reply #5 on: January 31, 2011, 08:15:30 pm » |
Humph, Looks like I scored a -karma for my efforts! Great system.  @Bobnova Since I figured you were using the cores from here . .. http://code.google.com/p/arduino-tiny/I tested those cores with my libs. After changing boards.txt to upload with the USBtinyISP I found that the TinyWireM lib worked with those cores. However, the sketch was running 10X slower - even the Blink sketch.  So I changed the speed in boards.txt from f_cpu=800000L to f_cpu=1000000L and now it works fine. I don't know why one set of cores uses an 8MHz clock and another set uses a 10MHz clock.
|
|
|
|
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #6 on: January 31, 2011, 10:25:09 pm » |
However, the sketch was running 10X slower - even the Blink sketch.  Was it 8X? So I changed the speed in boards.txt from f_cpu=800000L 800K is nowhere to be found in boards.txt. Was it an 8M entry you changed? to f_cpu=1000000L and now it works fine. Are the target processor's fuses set to run at 1 MHz? Or 8 MHz? I don't know why one set of cores uses an 8MHz clock and another set uses a 10MHz clock. The HIT core uses a 10 MHz clock?
|
|
|
|
|
Logged
|
|
|
|
|
Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« Reply #7 on: January 31, 2011, 11:02:25 pm » |
Kinda busting my chops on this aren't you? Was it 8X? Could have been 8X could have been 10X I didn't put a stopwatch on it. It was at least 8X. It is a critical difference for making a determination? 800K is nowhere to be found in boards.txt. Was it an 8M entry you changed? Ya got me! I dropped a 0 during the post. I changed it from 8MHz to 10MHz as I stated. As you know boards.txt in google code core is set for 8MHz. Are the target processor's fuses set to run at 1 MHz? Or 8 MHz? I suggest you look at the google code boards.txt and answer that yourself. I made no changes. The HIT core uses a 10 MHz clock? That's what I said. You can download the HIT core and verify that if you wish. In the google code site for the core you asked if someone would verify if these libraries would work with that core. This is what I've done, and this is, I guess, my thanks.
|
|
|
|
« Last Edit: January 31, 2011, 11:04:22 pm by BroHogan »
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #8 on: January 31, 2011, 11:34:08 pm » |
Kinda busting my chops on this aren't you? This is what I've done, and this is, I guess, my thanks. I do apologize for upsetting you. That was not my intention. I'm simply trying to determine if there is a problem with either core or if there is a misunderstanding on how either of them should work. I simply don't want another user to have the same problems that you've just had. Both cores should be simple to install and easy to use. I promise to refrain from any further communication. For what it's worth, I appreciate your efforts and thank you for your time.
|
|
|
|
|
Logged
|
|
|
|
|
Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« Reply #9 on: February 01, 2011, 01:41:10 pm » |
Well, I was wrong! Adamant, but wrong. I was posting instead of sleeping, and between cut & paste and counting zeros, I screwed up.
- boards.txt for HIT core is set for 1MHz. - boards.txt for "google code" core is set for 8MHz. (It also sets fuses which sets the internal clock speed.)
Nonetheless, when I used the "google code" core, Blink ran 8X slower. When I changed it from f_cpu=8000000L to f_cpu=1000000L it ran normally. Reloading again with the HIT core it continued to run normally.
It looks like the fuse settings in boards.txt for "google code" aren't getting set for some reason.
That's all I know. Sorry about the confusion.
In any case, the ATtiny I2C libs work with either core.
|
|
|
|
« Last Edit: February 02, 2011, 12:42:19 pm by BroHogan »
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Global Moderator
Dallas
Offline
Shannon Member
Karma: 129
Posts: 10402
|
 |
« Reply #10 on: February 02, 2011, 09:37:06 pm » |
- boards.txt for "google code" core is set for 8MHz. (It also sets fuses which sets the internal clock speed.)
It looks like the fuse settings in boards.txt for "google code" aren't getting set for some reason.
Ah! In order to change the fuse settings you have to select "ATtiny85 @ 8 MHz" then execute "Burn Bootloader". "Burn Bootloader" is also a nice way to clean the slate when switching to another project or putting a processor into storage. In addition to changing the fuse settings an empty do nothing Sketch is uploaded. Well, I was wrong! Adamant, but wrong. I was posting instead of sleeping, and between cut & paste and counting zeros, I screwed up. The moral of the story is ... friends don't let friends play with Arduinos when sleep deprived?  - boards.txt for HIT core is set for 1MHz. The "google code" should also have a "ATtiny85 @ 1 MHz" option. It should be almost identical in behaviour to the HIT core. In any case, the ATtiny I2C libs work with either core. Excellent news! Thanks!
|
|
|
|
« Last Edit: February 02, 2011, 09:39:06 pm by Coding Badly »
|
Logged
|
|
|
|
|
Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« Reply #11 on: February 03, 2011, 11:35:33 am » |
select "ATtiny85 @ 8 MHz" then execute "Burn Bootloader". Ive tried that, but I get errors. (Perhaps it's best I PM you on them, or start another thread.) In any case, I managed to set the fuses properly using Avrdude. (Every evening this week I found myself being drawn deeper and deeper into the dark side.  ) So now I am able to test the libs with both cores at both 1MHz and 8MHz. I wonder if anyone else has tried these libs yet.
|
|
|
|
« Last Edit: February 03, 2011, 11:38:46 am by BroHogan »
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Humboldt, CA
Offline
Full Member
Karma: 1
Posts: 220
Arduino BBB
|
 |
« Reply #12 on: February 03, 2011, 11:59:17 am » |
Sorry it took me so long to get back to you, it's been a hectic week around here. I got all set up with the scope this morning and the 4.9k resistor pull-ups, and the scope picture was perfect so I plugged in the digipot (which controls a fan pwm controller) and it worked perfectly too!
So either A) 3.9k resistor pull-ups do not work, or B) I didn't have them all the way inserted into the breadboard. In any case, you code is working perfectly for me, thanks! (I made no changes in software/firmware/sketch/etc)
Sorry if I cause you mental issues with my screwup!
Blink seems to be running the right speed for me, for whatever that is worth.
|
|
|
|
|
Logged
|
|
|
|
|
Denver
Offline
God Member
Karma: 19
Posts: 777
Inactive - PM
|
 |
« Reply #13 on: February 03, 2011, 12:04:40 pm » |
Aces! Great to hear. Thanks!
|
|
|
|
|
Logged
|
"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom." ~ Clifford Stoll
|
|
|
|
Offline
Jr. Member
Karma: 0
Posts: 64
|
 |
« Reply #14 on: April 02, 2011, 03:24:13 pm » |
bHogan,
I'm going to give this a try with attiny85 as i2c slave. Has anyone tried to implement onReceive and onRequest? Is there any fundamental reason why this would not work on attiny85?
Thanks for the work to date, George
|
|
|
|
|
Logged
|
|
|
|
|
|