//***************************************************************************** // //! \brief adc api interrupt state and data get test. //! //! \return None. // //***************************************************************************** static void adcIntTest(void) { // // Set the length of converter // // ADCConverLenSet(ADC1_BASE, 1, 1); // // Test ADC configure API // // ADCSequenceIndexSet(ADC1_BASE, ulAdcSeqNo, ulAdcSeqNo); // ADCSampLenSet(ADC1_BASE, 14, ADC_SAMPTIME_7_5_CYCLE); // // A/D interrupt enable // ADCIntEnable(ADC_BASE, ADC_INT_END_CONVERSION); xIntEnable(INT_ADC); xADCIntCallbackInit(ADC_BASE, ADC0IntFucntion); // // A/D configure // ADCConfigure(ADC_BASE, ADC_INPUT_SINGLE, ADC_OP_CONTINUOUS, ADC_TRIGGER_PROCESSOR); ADCProcessorTrigger(ADC_BASE); TestAssertQBreak("T", "xadc interrupt function error!", 0xFFFFFFFF); }
int main(void) { SetupIntc(); /* Initialize the UART console */ ConsoleUtilsInit(); /* Select the console type based on compile time check */ ConsoleUtilsSetType(CONSOLE_UART); ADCConfigure(); while(flag); val1 = (sample1 * RESOL_X_MILLION) / 1000; ConsoleUtilsPrintf("Voltage sensed on the AN0 line : "); ConsoleUtilsPrintf("%d", val1); ConsoleUtilsPrintf("mV\r\n"); val2 = (sample2 * RESOL_X_MILLION) / 1000; ConsoleUtilsPrintf("Voltage sensed on the AN1 line : "); ConsoleUtilsPrintf("%d", val2); ConsoleUtilsPrintf("mV\r\n"); while(1); }
/* ===================================================================*/ void ADCInit(void) { ADCEnable(); /* Clear ~CS, select ADC */ DelaySomeMs(1); ADCUseInternalClock(); /* Set CLKSEL, ADC uses internal clock */ DelaySomeMs(1); ADCStopConvertByHardware(); /* Clear START, ADC does not convert */ DelaySomeMs(1); ADCPowerUp(); /* Set ~PWDN */ DelaySomeMs(1); // ADCDirectConnect(); /* Use direct connect mode */ ADCResetByHardware(); /* Reset ADC when power on */ DelaySomeMs(1); ADCConfigure(); /* Configure the register of ADC. */ }
//***************************************************************************** // //! \brief adc api configure test. //! //! \return None. // //***************************************************************************** static void adcConfigTest(void) { // // Test ADC configure API // for(i=0; i<1; i++) { for(j=0; j<16; j++) { if((j==2)||(j==3)||(j==6)||(j==7)||(j==11)||(j==15)) { continue; } ADCConfigure(ulAdcAddress[i], ADC_INPUT_SINGLE, ADC_OP_SINGLE, ulTrigSrcReg[j]); ulReadVal = xHWREG(SIM_SOPT7) & ulTrigSrcReg[j]; TestAssert(j == ulReadVal, "xadc API error!" ); } } // // Test ADC configure API // for(i=0; i<1; i++) { ADCDMAEnable(ulAdcAddress[i]); ulReadVal = xHWREG(ulAdcAddress[i] + ADC0_SC2) & ADC0_SC2_DMAEN; TestAssert(ADC0_SC2_DMAEN == ulReadVal, "xadc API error!" ); } for(i=0; i<1; i++) { ADCDMADisable(ulAdcAddress[i]); ulReadVal = xHWREG(ulAdcAddress[i] + ADC0_SC2) & ADC0_SC2_DMAEN; TestAssert(0 == ulReadVal, "xadc API error!" ); } }