Hi,
the ATMEGA328PB has an ACO output on Port PE0.
How can I activate this output? Is it sufficient to set ACD=0? I couldn't figure this out from the latest datasheet.
Hi,
the ATMEGA328PB has an ACO output on Port PE0.
How can I activate this output? Is it sufficient to set ACD=0? I couldn't figure this out from the latest datasheet.
Try setting PE0 as an output, then in the ACSR reg, set ACD and ACO bits, this should get you the output you want.
Jim
Try setting PE0 as an output, then in the ACSR reg, set ACD and ACO bits, this should get you the output you want.
Jim
Thanks, I think I have found the solution now. According to the latest ATMEGA328PB datasheet, ACO is readonly. In application note AT15007 (from 2016), I found this:
2.5. Analog Comparator
Analog Comparator output is available on a pin. The analog comparator output is tied to PE0 when the AC output is enabled by writing a one to the Analog Comparator Output Enable bit (ACOE) in “ACSR0 –Analog Comparator Output Control Register”.
Finally, I looked into the avr support package, iom328pb.h:
#define ACSRB _SFR_IO8(0x2F) #define ACOE 0
This additional register ACSRB with the ACOE bit seems to be the solution. It's not documented in the ATMEGA328PB datasheet at all! (DS40001906C from 2018)
Nice catch, the latest datasheet register summary shows that address as "Reserved"
So this needs to be reported as a datasheet error.
How is that done, I did not find anything at MC/support.
Jim
Thanks. It worked