AnsweredAssumed Answered

ADuCM360 simultaneous sampling

Question asked by OlegTsvirko on Sep 22, 2015
Latest reply on Sep 28, 2015 by ABuda

Hello. I am trying to start simultaneous conversion on my EVAL-ADuCM360QSPZ as it said in Hardware User Guide (UG-367) Rev. D, Page 29:

Simultaneous Sampling

The ADuCM360 has two identical ADCs. These can be configured for simultaneous sampling. The filter settings of ADC1 (in ADC1FLT) are then automatically applied to ADC0.

To enable simultaneous sampling, follow these configuration steps:

  • Configure ADC0MDE and ADC1MDE.
  • Configure ADC1FLT.
  • Configure ADC0CON and ADC1CON as required but, ensure Bit 19 in both cases = 0
  • Set ADCCFG[15] = 1.

Both ADCs will then start converting at the same time and output data at the same rate.

 

But when I set ADCCFG[15] = 1 and SIMU become =1,  ADC0CON[19] and ADC1CON[19] is remains ADCEN=0, which means that both ADC's is powered down.

 

adc0registers.PNG


Could someone tell me what am I doing wrong?

 

This is my code:

#include <stdio.h>
#include <string.h>
#include <ADuCM360.h>
#include <math.h>
#include <stdlib.h> //for module


#include <..\common\AdcLib.h>
#include <..\common\ClkLib.h>
#include <..\common\WdtLib.h>
#include <..\common\IntLib.h>
#include <..\common\DioLib.h>
#include <..\common\SpiLib.h>
#include <..\common\PwmLib.h>
#include <..\common\FeeLib.h>
#include <..\common\GptLib.h>

//---------------------

char countEntry=0;
long array_xtek_ADC0[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};
long array_xtek_ADC1[20]={0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0};

//-------------                       

   volatile  long ulADC0Result = 0;                // Variable that ADC0DAT is read into in ADC0 IRQ   
   volatile  long ulADC1Result = 0;                // Variable that ADC1DAT is read into in ADC1 IRQ   

int main (void)
{
   pADI_WDT->T3CON = 0x00 ; // Disable watchdog timer
   WdtCfg(T3CON_PRE_DIV1,T3CON_IRQ_EN,T3CON_PD_DIS); // Disable Watchdog timer resets
   
   //Disable clock to unused peripherals
   ClkDis(CLKDIS_DISSPI0CLK|CLKDIS_DISI2CCLK|CLKDIS_DIST0CLK|CLKDIS_DIST1CLK|CLKDIS_DISUARTCLK|CLKDIS_DISDMACLK|CLKDIS_DISDACCLK);
   ClkCfg(CLK_CD0,CLK_HF,CLKSYSDIV_DIV2EN_DIS,CLK_UCLKCG);// Select CD0 for CPU clock - 16Mhz clock (62,5 ns)
   ClkSel(CLK_CD0,CLK_CD0,CLK_CD0,CLK_CD7);               // Spi, I2c,Urt,Pwm
//-----------------   

   pADI_GP0->GPCON |= 0x4000; // Set P0.7 pin as GPIO
   pADI_GP0->GPOEN |= 0xE0; // Set P0.5-P0.7 pins as output
   pADI_GP0->GPCLR |= 0xE0;// P0.5-P0.7 pins is low
   
   NVIC_EnableIRQ(ADC0_IRQn);                    // Enable ADC0 interrupt source
   NVIC_EnableIRQ(ADC1_IRQn);                    // Enable ADC1 interrupt source

   AdcMski(pADI_ADC0,ADCMSKI_RDY,1);  // Enable ADC0 ready interrupt source   
   AdcMski(pADI_ADC1,ADCMSKI_RDY,1);  // Enable ADC1 ready interrupt source   

    //PGA gain = 1, ADC is in Idle mode
    pADI_ADC0->MDE = 0x0003;
    pADI_ADC1->MDE = 0x0003;
   
    //ADC Filter Sinc Decimation factor = 32, Averaging factor = 0.
    //Second notch and choping is enabled.
    pADI_ADC0->FLT = 0xC0A0;
    pADI_ADC1->FLT = 0xC0A0;

    //Both external reference buffers powered down,
    //positive and negative reference buffers powered down and bypassed.
    //Bipolar (C type int) result.
    //Diagnostic currents disabled. Internal reference.
    //ADCEN=0. Power down the ADC, and clear the ADCxRDY bit.
    pADI_ADC0->CON = 0x0003C00F;
    pADI_ADC1->CON = 0x0003C02F;
   
    //Both external reference buffers are powered down and bypassed.
    //Simultaneous ADC sampling
    pADI_ADC1->ADCCFG = 0x8000;
   
    while (1)
     {
     }
   
}


ADC1_Int_Handler ()
{
   DioSet(pADI_GP0,0x40); //set high on p06
   ulADC1Result = AdcRd(pADI_ADC1);            // read ADC result register
   array_xtek_ADC1[countEntry]=  ulADC1Result;
     DioClr(pADI_GP0,0x40);//set low on p06
}

ADC0_Int_Handler ()
{
   DioSet(pADI_GP0,0x20); //set high on p05
   ulADC0Result = AdcRd(pADI_ADC0);            // read ADC result register
     array_xtek_ADC0[countEntry]=  ulADC0Result;     
     DioClr(pADI_GP0,0x20);//set low on p05
}

Outcomes