| Author |
Message |
|
|
Posted: Jun 27, 2012 - 10:07 PM |
|

Joined: Jun 27, 2012
Posts: 3
|
|
Hi,
My first post. please tell me if etiquette is broken or something is missing.
I am trying to use the ADC on the AVr Xmega 128A3. I am aware of the problems using the single-ended and 1V reference with this generation from Frank's blog. (http://blog.frankvh.com/2010/09/09/followup-to-atmel-xmega-adc-problems/#comments)
Attempting to read a -500mV to 500mV signal as fast as possible.
Before starting with multiple channels/interrupts: basic functionality. The result of the conversion is checked by outputting through the UART to a terminal in addition to sending the product to the DAC and to a scope.
The problems is that I see a constant 970 mV from the DAC on the scope and -128 is on the terminal. I have been wrestling with this for a while so any help is welcome.
The physical setup is according to Frank VH and somewhat what tpappano has suggested.
AREF= 2.048V reference voltage (pin 0)
Vneg input= going to ground (pin 1)
Vpos input= signal (pin 2)
the signal shares the ADC ground.
according to the transfer function: result=((Vpos-vneg)*(1/Vref))*2048, I should be receiving a number between -500 and 500.
everything is configured bitwise. The ADC is (supposed to be) signed, differential, no gain.
Code:
void ADCA0_single_init_12bit( void ) {
//enable the ADC
ADCA_CTRLA = ( 1 << ADC_ENABLE_bp );
//Set signed conversion mode, with 12 bit resolution (pg 301-302)
ADCA_CTRLB = ( 1 << ADC_CONMODE_bp )|( 0 << ADC_RESOLUTION0_bp)|( 0 << ADC_RESOLUTION1_bp);
//Set the ADC reference as the internal AREF (port A pin 0) reference, and turn on the bandgap, pg 304 Table 25-3
ADCA_REFCTRL = (0 << ADC_REFSEL0_bp)|( 1 << ADC_REFSEL1_bp )|( 1 << ADC_BANDGAP_bp);
//For now I am assuming the peripheral clock is 32 MHz until I can fix it. Tell the prescaler to divide by 512 to 64 kHz ( pg 306, Table 25-7 )
ADCA_PRESCALER = ( 1 << ADC_PRESCALER0_bp )|(1 << ADC_PRESCALER1_bp )|( 1 << ADC_PRESCALER2_bp );
//Set the gain to 1. Set the channel mode to differential input signal no gain (pg 309)
//ADCA_CH0_CTRL = ( 0 << ADC_CH_GAINFAC0_bp )|( 0 << ADC_CH_GAINFAC1_bp )|( 0 << ADC_CH_GAINFAC2_bp )|( 1 << ADC_CH_INPUTMODE1_bp )|( 0 << ADC_CH_INPUTMODE0_bp );
//Set the gain to 1. Set the channel mode to differential input signal no gain (pg 309)
ADCA_CH0_CTRL = ( 0 << ADC_CH_GAINFAC0_bp )|( 0 << ADC_CH_GAINFAC1_bp )|( 0 << ADC_CH_GAINFAC2_bp )|( 1 << ADC_CH_INPUTMODE1_bp )|( 0 << ADC_CH_INPUTMODE0_bp );
//Set the multiplexing controls. Set The negative input to pin 1 and the the positive input to pin 2 on port A
ADCA_CH0_MUXCTRL = ( 0 << ADC_CH_MUXPOS0_bp )|( 1 << ADC_CH_MUXPOS1_bp )|( 0 << ADC_CH_MUXPOS2_bp )|( 0 << ADC_CH_MUXNEG1_bp )|( 1 << ADC_CH_MUXNEG0_bp );
}
after calling this function, I get the product of the conversion by starting the channel conversion and reading the result register
Code:
ADCA_CTRLA = ( 1 << ADC_CH0START_bp )|( 1 << ADC_ENABLE_bp );
//get ADC_value
ADC_value = ADCA_CH0RES;
|
|
|
| |
|
|
|
|
|
Posted: Jun 29, 2012 - 02:29 PM |
|

Joined: Jan 24, 2008
Posts: 558
|
|
| Did you connect AVcc to anything? |
|
|
| |
|
|
|
|
|
Posted: Jun 29, 2012 - 03:26 PM |
|

Joined: Jun 27, 2012
Posts: 3
|
|
| Vcc has 3.3V from a power supply. Vin on Port A isn't connected to anything. |
|
|
| |
|
|
|
|
|
Posted: Jun 29, 2012 - 07:09 PM |
|

Joined: Jan 24, 2008
Posts: 558
|
|
| Not Vcc, AVcc. The analogue supply pin, pin 61. It must be connected to 3.3V as well. |
|
|
| |
|
|
|
|
|
Posted: Jul 03, 2012 - 02:32 PM |
|

Joined: Jan 24, 2008
Posts: 558
|
|
| AVcc was the answer then? |
|
|
| |
|
|
|
|
|
Posted: Jul 12, 2012 - 10:39 PM |
|

Joined: Jun 27, 2012
Posts: 3
|
|
Hi,
I thought I would get an email for a repost. I am still hacking away at it.
I am using Crumb Module for the ATXMega128A3. According to their datasheet all Vcc are internally connected. There is no pin associated with AVcc on their pinout sheet.
There is a pin labeled Vin which is not connected to Vcc. I don't know what that is.
So it is either AVCC and that is my problem or it is not and that is not my problem.
I am getting some output from the ADC. It is almost constant value reagardless of the datatype I read it as or the signal I give it. I don't know if that is an appopriate test of power.
Thanks.
http://shop.chip45.com/epages/es1064462 ... 8a3-1.2-08 |
|
|
| |
|
|
|
|
|
Posted: Jul 13, 2012 - 02:33 AM |
|


Joined: Dec 11, 2007
Posts: 6980
Location: Cleveland, OH
|
|
|
Quote:
So it is either AVCC and that is my problem or it is not and that is not my problem.
No, that isn't the problem.
The schematic shows the Vcc and AVcc pins all tied to V+, the Grounds tied to ground, and the chip is appropriately by-passed.
Note that there is not an LC Filter feeding the AVcc, so any noise on the V+ rail will be present on the ADC power supply. This is a fine point, however, and clearly isn't why you are not getting reasonable data.
I'll let others help with your code, that isn't my area.
JC |
|
|
| |
|
|
|
|
|
Posted: Jul 13, 2012 - 09:55 AM |
|

Joined: Jan 24, 2008
Posts: 558
|
|
| Did you check the power saving registers to make sure that the ADC is globally enabled and powered up on the port you want to use? |
|
|
| |
|
|
|
|
|
Posted: Jul 17, 2012 - 08:21 PM |
|


Joined: Feb 28, 2004
Posts: 976
Location: Ohio
|
|
I would actually recommend using the ASF for the XMEGA chips, and Atmel Studio 6. It has a lot of great examples. I would also recommend reading the app note for the XMEGA ADC.
You can find the ASF API documentation here.
It sounds to me like part of your problem is not compensating for the delta-V in the XMEGA ADC. You should measure that, and the gain offset if you are using differential with gain. |
_________________ I like cats, too. Let's exchange recipes.
|
| |
|
|
|
|
|