XMEGA AD converter

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

Hello

I tries to measure the internal temperature in a Xmega32A4 device bu get around 90 degC.
I have went through all documentation and set up the AD as described.
It also seems that the calibration (ADCA.CAL) has no effect.

My code is:

void AddADCInt(void)
{
   ADCA.CTRLB =  ADC_RESOLUTION_12BIT_gc | ( false ? ADC_CONMODE_bm : 0);   //12 bit, unsigned
    ADCA.REFCTRL = ADC_REFSEL_INT1V_gc | ADC_BANDGAP_bm | ADC_TEMPREF_bm;   
    ADCA.PRESCALER = ADC_PRESCALER_DIV512_gc;
    ADCA.CALH = (CLD.ADCACAL >> 8) & 0xff;    ADCA.CALL = CLD.ADCACAL & 0xff;

    ADCA.CH2.CTRL = ADC_CH_INPUTMODE_INTERNAL_gc | ADC_CH_GAIN_1X_gc;  // internal, gain 1
    ADCA.CH2.MUXCTRL = ADC_CH_MUXINT_TEMP_gc ;
    ADCA.CH2.INTCTRL = ADC_CH_INTLVL0_bm ;  
    ADCA.CTRLA |= ADC_ENABLE_bm;
       
    xTaskCreate( vADCIntTask, ( int8_t * ) "ADCInt", ADC_STACK_SIZE, NULL, tskIDLE_PRIORITY + 1 , ( xTaskHandle * ) NULL );

}
/*************************************************************************
*   (This is a task)
*  ADC (internal) handle task
*
*************************************************************************/
void vADCIntTask(void *pvParameters )
{

    while(true) {                                        // Task loop forever
        ADCA.CH2.CTRL |= ADC_CH_START_bm ;
        vTaskDelay(6);
    temperature = (358.0*((float)tst)/(float)CLD.TEMPSENSE)-273.15 ;

    }
}

/*************************************************************************
*  
*  ADC (internal) interrupt handler
*
*************************************************************************/
ISR ( ADCA_CH2_vect ){

    tst = (ADCA.CH2.RES);

}

Anybody knows what to do?

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

Check the errata. The XMEGA ADC has lots of bugs.

Leon Heller G1HSM

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

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

See "6-Internal temprature sensor readout in celsius":
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=viewtopic&t=104565

Ozhan KD
Knowledge is POWER