Analog Comparator output on ATMEGA328PB

Go To Last Post
5 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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.

 

 

This topic has a solution.
Last Edited: Wed. Mar 18, 2020 - 01:32 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

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

 

 

FF = PI > S.E.T

 

This reply has been marked as the solution. 
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ki0bk wrote:

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)

 

Last Edited: Wed. Mar 18, 2020 - 01:49 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0


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

 

 

FF = PI > S.E.T

 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thanks. It worked