Atmel Documentation lacking for Comparitor access Xmega128A1

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

Hi People

I want to use an XMega128A1 for its 4 comparators. However, no datasheet I have seen gives information on how to access the comparators.

The doc8077 downloaded from Atmel should contain this info, but does not. The Brief verson of the document details the fact the part has 4 comparators.

AVR1302 also fails to give any relevant detail.

This question has come up here ....

https://www.avrfreaks.net/index.p...

But no solution was offered in this thread. And that was December 2009!!

Anybody figure this out?
Thanx
Brian

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

the 128A1 is covered by TWO datasheets. 8077 is the generic "A manual" and covers all A models of Xmega. Then doc8067 is the A1 specific manual that covers the stuff local to the A1 models including the 128A1. The Analog Comparator is coverded in chapter 26 of that document (well it's chapter 26 in the version I have anyway).

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

Hi clawson ... thanx for taking time to respond.

I have both docs you mention. The 8067 is a rather useless document that contains a brief overview of the features of said cpu. It mentions no registers in regards to comparator.

The larger 8077 manual is what I would use, but regards the comparator, it only provides details/register information to a single comparator. I would like to use all 4 and need the detailed register description pertaining to the other registers. This info seems not to exist.

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

Quote:

I would like to use all 4 and need the detailed register description pertaining to the other registers.

But surely all 4 are the same? The A manual tells you about ACnCTRL, ACnMUXCTRL, CTRLA, CTRLB, WINCTRL, STATUS where n=0 or 1). And the A1 manual tells you:
Quote:
The Analog Comparators are always grouped in pairs (AC0 and AC1) on each analog port. They have identical behavior but separate control registers.
Optionally, the state of the comparator is directly available on a pin.
PORTA and PORTB each has one AC pair. Notations are ACA and ACB, respectively.

So the four are going to be ACA.0, ACA.1, ACB.0 and ACB.1

Then looking at iox128a1.h confirms:

#define ACA    (*(AC_t *) 0x0380)  /* Analog Comparator A */
#define ACB    (*(AC_t *) 0x0390)  /* Analog Comparator B */

and also:

/* Analog Comparator */
typedef struct AC_struct
{
    register8_t AC0CTRL;  /* Comparator 0 Control */
    register8_t AC1CTRL;  /* Comparator 1 Control */
    register8_t AC0MUXCTRL;  /* Comparator 0 MUX Control */
    register8_t AC1MUXCTRL;  /* Comparator 1 MUX Control */
    register8_t CTRLA;  /* Control Register A */
    register8_t CTRLB;  /* Control Register B */
    register8_t WINCTRL;  /* Window Mode Control */
    register8_t STATUS;  /* Status */
} AC_t;

So the registers to use are:

ACA.AC0CTRL
ACA.AC1CTRL
ACA.AC0MUXCTRL
ACA.AC1MUXCTRL
ACA.CTRLA
ACA.CTRLB
ACA.WINCTRL
ACA.STATUS

ACB.AC0CTRL
ACB.AC1CTRL
ACB.AC0MUXCTRL
ACB.AC1MUXCTRL
ACB.CTRLA
ACB.CTRLB
ACB.WINCTRL
ACB.STATUS

So what's left to know that has not been said by the datasheet(s)?

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

Quote:

The larger 8077 manual is what I would use, but regards the comparator, it only provides details/register information to a single comparator. I would like to use all 4 and need the detailed register description pertaining to the other registers. This info seems not to exist.

Perhaps the missing piece is "30. Peripheral Module Address Map" which gives the base address for each of the peripherals for that particular Xmega model.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

Quote:

which gives the base address

Though if programming C do you really need to know that detail? I happen to know that on mega16 DDRB is at 0x04 and PORTB is at 0x05 but do I really need to know that in order to use those registers in a C program?

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

Quote:

Though if programming C do you really need to know that detail? I happen to know that on mega16 DDRB is at 0x04 and PORTB is at 0x05 but do I really need to know that in order to use those registers in a C program?


Well, it puts things into perspective, seeing how all the pieces fit together IMO. It seemed to be what OP was missing.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

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

clawson... your right. I am overlooking something and being confused at the same time.

If you look at CTRLA, it has only 1 active bit which references AC0OUT only. I was expecting to find a dedicated bit to configure each of the Analog comparators. The cpu device spec says 4 comparators, but they seem to work in 2 pairs somehow. This is all very confusing for now. Need to study this lot in more detail to get my head around it all.