Hi,
I used a mashup of Project Explorer examples provided to repeat single conversions by command.
The input voltage on gpio pin is ~ 1VDC.
What I am seeing is that if I command to measure on the order of one second per measurement, each measuremen'st return value decreases.
If I wait a few seconds between measurements, I see the full 1 VDC.
Is there some sort of recovery time between measurements needed?
I'm going to try to cut and paste the code of interest below:
/*
* -----------------------------------------------------------------------------
*/
int a2d_init(void)
{
int status =0;
/*
* example modified from ti resource explorer, adc14_single_conversion_repeat
* floating point init moved to reu_init()
*
* something in this routine is critical and must be called before every measurement
*/
MAP_REF_A_setReferenceVoltage(REF_A_VREF2_5V);
MAP_REF_A_enableReferenceVoltage();
/* Initializing ADC (MCLK/1/4) */
MAP_ADC14_enableModule();
/* ADC_NOROUTE = map to external pin */
MAP_ADC14_initModule(ADC_CLOCKSOURCE_MCLK, ADC_PREDIVIDER_1, ADC_DIVIDER_4,ADC_NOROUTE);
/* Enabling interrupts */
MAP_ADC14_enableInterrupt(ADC_INT0);
MAP_Interrupt_enableInterrupt(INT_ADC14);
MAP_Interrupt_enableMaster();
// configure nor trigger done here.
return status;
} // end a2d_init
int a2d_set_get(int port, int pin, uint16_t *adc_valp)
{
int status =0;
int ii;
a2d_f = false; // see ADC14_IRQHandler()
a2d_init();
/* Configuring GPIOs (5.1 A4) */
MAP_GPIO_setAsPeripheralModuleFunctionInputPin(port, pin,
GPIO_TERTIARY_MODULE_FUNCTION);
/* Configuring ADC Memory */
MAP_ADC14_configureSingleSampleMode(ADC_MEM0, true);
MAP_ADC14_configureConversionMemory(ADC_MEM0, ADC_VREFPOS_AVCC_VREFNEG_VSS,
ADC_INPUT_A0, false);
/* Configuring Sample Timer */
MAP_ADC14_enableSampleTimer(ADC_MANUAL_ITERATION);
/* Enabling/Toggling Conversion */
MAP_ADC14_enableConversion();
MAP_ADC14_toggleConversionTrigger();
for (ii=0; ii<50; ii++) // loop for a while waiting for done
{
if (a2d_f) // mutex set in interrupt handler
break;
DelayMs(100);
}
if (!a2d_f)
{
status = -1; // never triggered
sprintf(g_info,"The A/D never triggered.\r\n ");
if (g_uartbase != 0) // if comms path has been initialized
{
putUsart(g_info); // output to known path
}
else
{
putUsartSel(1,0,g_info); // else who is listening?
putUsartSel(3,0,g_info);
}
}
else
{
*adc_valp = curADCResult; // value set in interrupt handler
}
return status;
} // end a2d_set_get
void ADC14_IRQHandler(void)
{
uint64_t status = MAP_ADC14_getEnabledInterruptStatus();
MAP_ADC14_clearInterruptFlag(status);
if (ADC_INT0 & status)
{
curADCResult = MAP_ADC14_getResult(ADC_MEM0);
//MAP_ADC14_toggleConversionTrigger(); // was in example, not needed
a2d_f = true;
//MAP_ADC14_disableConversion(); // needs re-init after else leads to no interrupt
}
} /* end ADC14_IRQHandler */