我是用 BSP 的 EADC_ADINT_Trigger 範例修改的 
 
/*---------------------------------------------------------------------------------------------------------*/ 
/* EADC function test                                                                                       */ 
/*---------------------------------------------------------------------------------------------------------*/ 
void EADC_FunctionTest() 
{ 
 
 
            /* Set the ADC internal sampling time, input mode as single-end and enable the A/D converter */ 
            EADC_Open(EADC, EADC_CTL_DIFFEN_SINGLE_END); 
            EADC_SetInternalSampleTime(EADC, 6); 
 
            /* Configure the sample 4 module for analog input channel 0 and enable ADINT0 trigger source */ 
            EADC_ConfigSampleModule(EADC, 4, EADC_ADINT0_TRIGGER, 0); 
            /* Configure the sample 5 module for analog input channel 1 and enable ADINT0 trigger source */ 
            EADC_ConfigSampleModule(EADC, 5, EADC_ADINT0_TRIGGER, 1); 
            /* Configure the sample 6 module for analog input channel 2 and enable ADINT0 trigger source */ 
            EADC_ConfigSampleModule(EADC, 6, EADC_ADINT0_TRIGGER, 2); 
            /* Configure the sample 7 module for analog input channel 3 and enable ADINT0 trigger source */ 
            EADC_ConfigSampleModule(EADC, 7, EADC_ADINT0_TRIGGER, 3); 
 
            /* Clear the A/D ADINT0 interrupt flag for safe */ 
            EADC_CLR_INT_FLAG(EADC, 0x1); 
 
            /* Enable the sample module 7 interrupt */ 
            EADC_ENABLE_INT(EADC, 0x1);//Enable sample module  A/D ADINT0 interrupt. 
            EADC_ENABLE_SAMPLE_MODULE_INT(EADC, 0, (0x1 << 7));//Enable sample module 7 interrupt. 
            NVIC_EnableIRQ(ADC00_IRQn); 
 
            /* Reset the ADC indicator and trigger sample module 7 to start A/D conversion */ 
            g_u32AdcIntFlag = 0; 
            g_u32COVNUMFlag = 0; 
            EADC_START_CONV(EADC, (0x1 << 7)); 
 
 
} 
 
 
        uint32_t i32ConversionData[4] ; 
/*---------------------------------------------------------------------------------------------------------*/ 
/* EADC interrupt handler                                                                                  */ 
/*---------------------------------------------------------------------------------------------------------*/ 
void ADC00_IRQHandler(void) 
{ 
                uint8_t u32SAMPLECount ; 
    EADC_CLR_INT_FLAG(EADC, 0x1);      /* Clear the A/D ADINT0 interrupt flag */ 
                for(u32SAMPLECount = 0; u32SAMPLECount < 4; u32SAMPLECount++) 
                        i32ConversionData[u32SAMPLECount] = EADC_GET_CONV_DATA(EADC, (u32SAMPLECount + 4)); 
} 
 
/*---------------------------------------------------------------------------------------------------------*/ 
/*  Main Function                                                                                          */ 
/*---------------------------------------------------------------------------------------------------------*/ 
int32_t main(void) 
{ 
    SYS_UnlockReg(); 
    SYS_Init(); 
    SYS_LockReg(); 
    UART0_Init(); 
    EADC_FunctionTest(); 
 
    while(1){ 
                         
         //   for(g_u32COVNUMFlag = 0; (g_u32COVNUMFlag) < 8; g_u32COVNUMFlag++) 
           //     printf("Conversion result of channel %d: 0x%X (%d)\n", (g_u32COVNUMFlag % 4), i32ConversionData[g_u32COVNUMFlag], i32ConversionData[g_u32COVNUMFlag]);         
                         printf("Conversion result of channel %d: 0x%X (%d)\n", (0 % 4), i32ConversionData[0], i32ConversionData[0]);         
                        printf("Conversion result of channel %d: 0x%X (%d)\n", (1 % 4), i32ConversionData[1], i32ConversionData[1]);         
                        printf("Conversion result of channel %d: 0x%X (%d)\n", (2 % 4), i32ConversionData[2], i32ConversionData[3]);         
                        printf("Conversion result of channel %d: 0x%X (%d)\n", (3  % 4), i32ConversionData[3], i32ConversionData[3]);         
                                         
                } 
 
} |