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.

unable to get the adc data in analog pin PE4 in Tiva c TM4c1294xl launch pad.

void
ReadAdc(void)
{
  //  schedule();
    uint32_t pui32ADC0Value[1];


     while(1)
         {
             //
             // Trigger the ADC conversion.
             //
             ADCProcessorTrigger(ADC0_BASE, 3);

             //
             // Wait for conversion to be completed.
             //
             while(!ADCIntStatus(ADC0_BASE, 3, false))
             {
             }

             //
             // Clear the ADC interrupt flag.
             //
             ADCIntClear(ADC0_BASE, 3);

             //
             // Read ADC Value.
             //
             ADCSequenceDataGet(ADC0_BASE, 3, pui32ADC0Value);

             //
             // Display the AIN0 (PE7) digital value on the console.
            // uint32_t val=((1475 * 1023) - (2250 * pui32ADC0Value[0])) / 10230;
             //
             UARTprintf("%4d\r", pui32ADC0Value[0]);

             //
             // This function provides a means of generating a constant length
             // delay.  The function delay (in cycles) = 3 * parameter.  Delay
             // 250ms arbitrarily.
             //
             SysCtlDelay(SysCtlClockGet() / 12);
         }

}



void
ConfigureADC0(void)
{
    SysCtlPeripheralEnable(SYSCTL_PERIPH_ADC0);
        SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOE);
        GPIOPinTypeADC(GPIO_PORTE_BASE,GPIO_PIN_4);

        // *** ADC0
        ADCSequenceConfigure(ADC0_BASE,3,ADC_TRIGGER_PROCESSOR,0);
        ADCSequenceStepConfigure(ADC0_BASE,3,0,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);
        ADCSequenceEnable(ADC0_BASE,3);
        //ADCIntRegister(ADC0_BASE,3,&ADC0SS3IntHandler);
        // *** GPIO

        ADCIntClear(ADC0_BASE, 3);



}

  • //
    // Run from the PLL at 120 MHz.
    //
    g_ui32SysClock = MAP_SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |
    SYSCTL_OSC_MAIN |
    SYSCTL_USE_PLL |
    SYSCTL_CFG_VCO_480), 120000000);
  • duraisamy pandurangan said:
    ADCSequenceStepConfigure(ADC0_BASE,3,0,ADC_CTL_CH0|ADC_CTL_IE|ADC_CTL_END);

    PE4 alternative function is AIN9, so try ADC_CTL_CH9 instead.

    - kel

  • duraisamy pandurangan said:
    // Display the AIN0 (PE7) digital value on the console. 

    We note:

    a) the above comment w/in poster's code

    b) poster's code addresses CH_0

    c) Aiding poster Markel offers CH_9

    Poster appears to have (bit mechanically) cut/pasted - w/out full read/review of his code.

    Perhaps AIN0 "is" PE7 on "some" MCU - but I'd "try" Markel's suggestion before resorting to (God forbid) "a read of the MCU manual..."