analogRead() on Attiny13

I had an Attiny85 in a circuit performing functions that I thought could also be done by the smaller Attiny13, so I programmed the attiny13 with the same code as the attiny85, swapped both chips, tested my circuit and nothing happened……..
Flipped the attiny85 back in, worked correct, put the attiny13 in, didnt work.
Basically what the circuit does is to read two analog values, compare these and switch an output depending on the values read.
I stripped out all the functions to get to the bare necessity of reading only one analog port… what could be wrong with that? but still it didnt work.
Though debugging is a bit difficult with an attiny13 -you sort of have to guess whats going on- but I suspected the analogRead to somehow hang.
As I am using the ‘smeezekitty’ core and smeezekitty states that  that could happen with an older core, I made sure I had an update, but again the same problem..
Anyway, after long searches i fugured i had to add the “analogReference(0)” statement in the setup and indeed that worked.
So the setup of my program became:

void setup()
#ifdef __AVR_ATtiny13__
analogReference(0);//this line is essential for the Attiny13

ofcourse you could leave out the conditional parameters but this way the code is suitable for the 13 and for the 25/45/85 series

6 thoughts on “analogRead() on Attiny13”

  1. Thank you for the advice, but it didn’t work. I finally ended up using the AVR commands instead

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.