This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

AMIC110: ADC voltage measurements

Part Number: AMIC110

Hi 

I'm trying to read the 8 channels of the ADC on an AMIC110ICE board.  I know that the pins are not brought out to the outside world, but I was hoping to read at least some noise, but all the numbers coming out are identically 0.  I doubt that's correct...

I have set up the steps to provide me with the step ID, and I am setting up one step for each of the 8 channels.  My readout software correctly sees and decodes the step ID, but the data in it is all zeros.  I'm thinking I have missed a setup step somewhere.  I've modeled this after the starterware/examples/adc/volt_measure example.  I've not enabled the interrupts to help simplify the process.    Here is the code I use to iniitialize the ADC.  When I check a ittle while after initializing, I have 4 words in each FIFO, and they have the tags.  But no numbers where there should be numbers in the FIFO data.  Thanks for any pointers!

void init_housekeeping()
{
int fifo, status;
tscAdcStepCfg_t adcStepCfg;

// power AFE up.
TSCADCAfePowerUp( TSCADC_BASE_ADDR );

/* Configure the ADC interrupts. */
// status = housekeeping_AdcIntrConfig(&data_ready);

// ADC clock divider register. AMIC110 is limited to 3 MHz. Let's use 2

TSCADCClkDivConfig( TSCADC_BASE_ADDR,TSCADC_MODULE_CLOCK,TSCADC_AFE_CLOCK);
/* Enable the step ID tag. */
TSCADCStepIdTagEnable(TSCADC_BASE_ADDR, TRUE);

/* Disable the write protection for Step config registers. */
TSCADCStepConfigProtectionEnable(TSCADC_BASE_ADDR, FALSE);

adcStepCfg.adcNegativeInpRef = TSCADC_NEGATIVE_REF_VSSA;
adcStepCfg.adcPositiveInpRef = TSCADC_POSITIVE_REF_VDDA;
adcStepCfg.adcNegativeInpChan = TSCADC_NEGATIVE_REF_VSSA;
adcStepCfg.adcPositiveInpChan = TSCADC_INPUT_CHANNEL1;
adcStepCfg.enableXppsw = FALSE;
adcStepCfg.enableXnpsw = FALSE;
adcStepCfg.enableYppsw = FALSE;
adcStepCfg.enableXnnsw = FALSE;
adcStepCfg.enableYpnsw = FALSE;
adcStepCfg.enableYnnsw = FALSE;
adcStepCfg.enableWpnsw = FALSE;

/* Enable ADC for GP mode. */
TSCADCTSModeConfig(TSCADC_BASE_ADDR, TSCADC_MODE_GP_ADC);

// Configure the steps, using the same step config for each
// Use FIFO 0 for channel 1-4, FIFO 1 for channels 5-8
for( int i = 1 ; i <= 8; i++)
{
adcStepCfg.adcNegativeInpChan = TSCADC_INPUT_VREFN;
adcStepCfg.adcPositiveInpChan = i;
TSCADCStepConfig(TSCADC_BASE_ADDR, i,
FALSE, &adcStepCfg);
TSCADCStepMode (TSCADC_BASE_ADDR, i,
TSCADC_STEP_MODE_SW_ENABLED_ONE_SHOT);
TSCADCStepDelayConfig(TSCADC_BASE_ADDR, i,SAMPLE_DELAY,OPEN_DELAY);
TSCADCStepIdTagEnable(TSCADC_BASE_ADDR,TRUE);
TSCADCStepSamplesAvg(TSCADC_BASE_ADDR, i,
TSCADC_SAMPLES_AVG_16);
if(i > 4)
fifo = TSCADC_FIFO_SEL_1;
else
fifo = TSCADC_FIFO_SEL_0;
TSCADCStepFifoConfig(TSCADC_BASE_ADDR, i,
fifo, FIFO_DEPTH_SETTING, FALSE);
//TSCADCFIFOIRQThresholdLevelConfig(TSCADC_BASE_ADDR, i,
// fifo, FIFO_DEPTH_SETTING, TRUE);
}
restart_housekeeping();
TSCADCEnable(TSCADC_BASE_ADDR, TRUE);
}

Here's the readout code:

void read_housekeeping_adcs()
{
int count,fifo,id;
uint32_t fifo_data;
// restart the conversions for next time.

UART_printf("Reading housekeeping ADC data...\r\n");
for( int i = 0; i < 2; i++ )
{
if ( i == 0 )
fifo = TSCADC_FIFO_SEL_0;
else
fifo = TSCADC_FIFO_SEL_1;
count = TSCADCGetFifoWordCount(TSCADC_BASE_ADDR,fifo);
while (count-- != 0)
{
// read the data out of the FIFO
// Decode the ID
// Decode the data and put it in the array
fifo_data = TSCADCGetFullFifoData(TSCADC_BASE_ADDR,fifo);
id = fifo_data >>16 ;
housekeeping_data[id] = fifo_data & 0xFFF;
UART_printf("C:%d id:%d hdta:%x data:%x\r\n ",count,id,housekeeping_data[id],fifo_data);
}
}
restart_housekeeping();
user_delay(10000000);
UART_printf("Done.\r\n");
}

Here's the screen output from a run:

Reading housekeeping ADC data...
C:3 id:0 hdta:0 data:0
C:2 id:1 hdta:0 data:10000
C:1 id:2 hdta:0 data:20000
C:0 id:3 hdta:0 data:30000
C:3 id:4 hdta:0 data:40000
C:2 id:5 hdta:0 data:50000
C:1 id:6 hdta:0 data:60000
C:0 id:7 hdta:0 data:70000

  • Hi John, 

    I'm also trying the same EtherCAT with ADC implementation. Initially, I tried to use the starterware/examples for ADC but there were many difficulties while including them in ethercat stack files. However I managed to use the dal files for ADC, now I'm able to use that and building successfully. But application running fails when attempt to read/write ADC hardware registers.

    void TSCADCAfePowerUp(uint32_t baseAddr)
    {
    /* Power up the ADC. */
    HW_WR_FIELD32((baseAddr + ADC0_CTRL), ADC0_CTRL_POWER_DOWN,
    ADC0_CTRL_POWER_DOWN_AFEPOWERUP);
    }

    baseAddr was 0x44E0D000.

    Analog pins(AN0 and AN1) are configured using TI Pinmux tool and included in pinmux configuration. Added MMU configuration for ADC as well.

    var peripheralAttrs = {
    type : Mmu.FirstLevelDesc_SECTION, // SECTION descriptor
    tex: 0,
    bufferable : false, // bufferable
    cacheable : false, // cacheable
    shareable : false, // shareable
    noexecute : false, // not executable
    };

    var peripheralBaseAddr = 0x44E0D000;
    Mmu.setFirstLevelDescMeta(peripheralBaseAddr, peripheralBaseAddr, peripheralAttrs);

    Do you think I'm missing anything it would be really helpful.

    Thanks and regards,

    Akash

  • Missed to configure clock for ADC. Enabling CM_WKUP_ADC_TSC_CLKCTRL register fixed the issue.

  • Glad you figured it out.  I had a similar problem and it turned out that I had not powered up the ADC module: in Board_moduleClockInit() at Jianzhong's suggestion I added:

    // ADC module enable
    if(S_PASS == status)
    {
    status = PRCMModuleEnable(CHIPDB_MOD_ID_ADC0, 0U, 0U);
    }

  • John,

    Have you tried to build and run the ADC example in starterware as is? The build commands are:

    C:\ti\pdk_am335x_1_0_17\packages>pdksetupenv.bat
    C:\ti\pdk_am335x_1_0_17\packages\ti\starterware>gmake adc_app_volt_measure -s PLATFORM=am335x-evm SOC=am335x PROFILE=debug
    

    Regards,

    Jianzhong

  • Just tried this. It seems to do something more useful...  I'll play some more with my code...  Thanks for the suggestion.

    StarterWare ADC voltage measure application!!
    BOARDInit status [0x0]
    SoC : [AM335X]
    Core : [A8]
    Board Detected : [AMIC110]
    Base Board Revision : [UNKNOWN]
    Daughter Card Revision: [UNKNOWN]
    Voltage sensed on the AN0 line :1794mV
    Voltage sensed on the AN1 line :0mV

  • That's good to know.