ilovetoflyfpv:
Hi OldSteve
Sorry to take so long to get back to you. I had a chance to sit down this evening and test whether a simple sketch would compile using analogReference(INTERNAL2V56).void setup() {
analogReference(INTERNAL2V56);
}
void loop() {
}
Unfortunately I get the following error.
Right. That's a core-dependent thing then. The David Mellis core that you're using differs from DrAzzy's core in that respect. (I'll address what a core is further down.
)
Your code above compiles fine for me.
If I however change the sketch.
void setup() {
analogReference(INTERNAL);
}
void loop() {
}
My code compiles. 2.56V is my preference reference. ;)
Are you sure that the above will set the reference to 2.56V, and not 1.1V?
It's a bit ambiguous. Using an UNO board, for instance, that would set the reference to 1.1V. That's another good reason to use DrAzzy's core, besides the fact that it supports a wider range of chips and configurations, and is more up-to-date.
Personally, I like the fact that when using DrAzzy's core, you can use "INTERNAL2V56" or "INTERNAL1V1", because there's no ambiguity about the reference voltage, unlike when using "INTERNAL", when a chip has multiple internal references available.
I've done some further searching and found the following thread on the Arduino forum.
analogReference on ATTiny85If you check out specifically post #6 there is a odd suggestion involving defining a constant. I'm not quite sure what's happening here although if I copy and paste the code it does compile?
![]()
#define INTERNAL2V56_NO_CAP (6)
The above just defines "INTERNAL2V56_NO_CAP" to be equal to the value 6. It effectively means that you could use:-analogReference(6);(Which, incidentally, compiles fine for me.)
PS I'm not sure what 'Core' means? I've tried reading up on this and have also spoken to a retired Electrical Engineering lecturer and the best I've come up with is it's the guts of the chip???
In this context, "core" means the files that are used by the IDE to relate to a particular chip or board. For the ATtiny range, the two most commonly used cores are the one by David Mellis, and the newer one by DrAzzy that I'm using.
To avoid the ambiguities that you're experiencing with the ealier core, I'd highly recommend using DrAzzy's instead. Like the David Mellis tiny cores, it can be installed by adding a line to "Additional Boards Manager URLs" in ">File >Preferences".
If you're interested, there's more info here:- ATTinyCore
DrAzzy is a regular visitor to the forums, too, contributing on a daily basis.