September 6, 2021, 9:07pm
wondering if anyone can help. I have a homemade board with an Atmega16u2, been using it for months on two different projects with no problem.
the 16u2 has an arduino bootloader, that i installed with avrdude, called Hoodloader2 (bootloader code and board file by GitHub - NicoHood/HoodLoader2: 16u2 Bootloader to reprogram 16u2 + 328/2560 with Arduino IDE).
i recently added some new statements in my code and i got compile errors:
#define capground A2
error: 'A2' was not declared in this scope
ACMUX = 3
error: 'ACMUX' was not declared in this scope
i also have this statement
ACSR |= (1<<7); which the compiler does recognize. The ACSR and ACMUX are registers for the analog comparator.
i'm guessing there's an error in the board file, but God knows where it is. Has anyone else ever used Hoodloader2?
September 6, 2021, 9:36pm
is that code in the main .ino file or a separate .cpp file?
I had the same experience in the past.
This is a mistake in the AVR toolchain. The maintainer of this is a Microchip...
Please add it yourself.
#define ACMUX _SFR_MEM8(0x7D)
#defnie CMUX0 0
#defnie CMUX1 1
#defnie CMUX2 2
September 6, 2021, 11:52pm
in the ino code, there aren't any included files.
September 6, 2021, 11:54pm
lol that's what i thought for a minute. But the chip doc says ACMUX in several places.
September 7, 2021, 12:42am
The ATmega16U2 doesn't have an ADC, only an analog comparator (AC).
September 7, 2021, 2:35am
"I had the same experience in the past. This is a mistake in the AVR toolchain"
wow. NO WAY i woulda ever figured that out. Thank God 4 ur experience
September 7, 2021, 2:45am
"The ATmega16U2 doesn't have an ADC"
even if it did it would only have a resolution of 5mV so i would still need to use the comparator to get single mV measurements
January 5, 2022, 2:46am
This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.