DigiSpark and ATTiny45 behaving quite differently..

This centered around the PWM functionality of ATTiny via ArduinoIDE.. let's say I have a very simple program with pinMode(0, OUTPUT); the loop

analogWrite (0, 100);

And I'm getting huge flicker from the ATTiny. And the "Fade" example, and etc. It does handle digitalWrite fine so far. Meanwhile, the DigiSpark, on the same pin and code, runs like Arduino. From what I can tell, Arduino as ISP is working great. I followed the trail of crumbs and burned ATTiny bootloaders to run at 8mhz and 16mhz internal PLL clock, respectively. From 1 to 8mhz, the delay intervals did change noticeably. I changed the time durations even trying millis(). And it obviously sounds fairly digital via Ohmmeter.

So before I surrender and buy the mini brick of digisparks, can someone give me an idea on some different tests or workarounds? I'm tentative to dive into C if I can get away with DigiSpark.. but I'm definitely curious.

Edit: I've tried 3 ATTiny's from same batch with same result

Before you get all aggitated, best to read my project about taking a standard Trinket (t85) and converting it to a DigiSpark clone: http://www.hackster.io/rayburne/trinket-firmware-exorcism

All is explained.

A companion project discuss building an Adafruit Trinket clone: http://www.hackster.io/rayburne/chachka-trinket-attiny85-clone

Ray

Ray this is great info, thanks! I will def do this if I get a Trinket, and you think it's ATTiny45 compatible? I see that in one line of the code it says "Device looks like ATTiny85!" I trust your input here, as I assume the only dif is memory size. I have 5 and 0 of them are useful to me without PWM, so I will definitely be trying this on one of them soon.

Well, the rabbit hole is deep, and it went to a different place called.. usbasp, a perfboard crosswired, and avrdude.. which ended pretty well, with this very satisfying output..

avrdude.exe: input file Digispark02.ino.hex auto detected as Intel Hex
avrdude.exe: input file Digispark02.ino.hex contains 502 bytes
avrdude.exe: reading on-chip flash data:

Reading | ################################################## | 100% 0.24s

avrdude.exe: verifying ...
avrdude.exe: 502 bytes of flash verified

avrdude.exe done.  Thank you.

However, I found the digiSpark "cores" library a bit big and confusing.. and I didn't know quite which file I'm really after. Any more hints? PWM still quite broken, and I'm a bit skeptical I can get T45 to work well because in documentation they specifically rule out 40's. I don't care tho, I have an extra!! And seems worth a try.

Thanks :)

willPsi: Ray this is great info, thanks! I will def do this if I get a Trinket, and you think it's ATTiny45 compatible? I see that in one line of the code it says "Device looks like ATTiny85!" I trust your input here, as I assume the only dif is memory size. I have 5 and 0 of them are useful to me without PWM, so I will definitely be trying this on one of them soon.

@willPsi: I'm not a tiny45 user, but I have lots of tiny85 experience... although I've been in 32-bit land for a couple of years.

From my (cursory understanding) the t45 and t85 are 4K flash/256 SRAM vs 8K flash/512 SRAM, other specs being similar.

So, essentially the t45 is one-half the t85... I guess the marketing team did not want to call the t45 a "t42.5" and just rounded the model to t45 :o

SRAM is always an issue in these little devices when one programs under Arduino... try a blank-sketch to see what the overhead is...

When using 3 PWM signals on the t85, you do have to set the fuses to lose the Reset pin which could be a problem ... it is a one-way setting without an hv-programmer to reset the fuses.

The DigiSpark has a nice set of libraries and almost all work with the t85 Trinket which greatly extends the Adafruit device usefulness. But, using any bootloader is a hog on the flash - ISP is a better approach IMO.

Good luck. Mouser sells a tube of qty 25 attiny85 for under $2 each which is how I used to buy several years ago but the cost was more like $1.25 USD then.

Ray

Seriously, the tiny series is fun and I have several projects published around thst uC ... but IMO thebest bang-for-the-buck is the ESP8266 on the NodeMCU board for $3 per unit. This is my pick for the toy of the summer!

Wow Ray pretty amazing what can be had for $3!! Entirely beyond me for now, is 32B land as you call it :) Thanks again for the insight.

I want to flash the digispark bootloader via USBAsp and avrdude, but I'm digi-stumped about the relevant file. In the digistump drivers there are two files, DigiSpark_Bootloader.cat, and DigiSpark_Bootloader.inf. Am I close to finding the right one, with perhaps a mere renaming?

The PWM issue is horrible flicker on the T45 on the "Fade" example, on Pin0 (physical pin 5). So if Digispark does work, and I burn that bootloader, I'm all set!

Definitely not worried about the reset pin, seeing as I just found a link to use Arduinio as ISP for high voltage!! http://www.rickety.us/2010/03/arduino-avr-high-voltage-serial-programmer/

well, I threw another command at it... which unfortunately involved a -F because of a device signature mismatch (duh) between T85 and T45. So I went ahead anyway..

avrdude.exe -c usbasp -p Attiny85 -F -U flash:w:micronucleus-1.06-upgrade.hex -U lfuse:w:0xe1:m -U hfuse:w:0x5d:m -U efuse:w:0xfe:m >"history.txt"

And that seemed to be the last attempt before a high voltage fix for this little chip.. I'm not disappointed it was a good learning experience and what I'm gathering is that T45 isn't supported in same way T85 is, so I should be receiving some T85's soon and we can try again.

In the meantime I got a new method for working with the Tiny's which doesn't involve Arduino as ISP and so, nothing to complain about :)

TTiny flash jig