2、既然用查询方式,建议不要使能中断。按如下修改:
- void EADC_Init()
- {
- SYS_ResetModule(EADC_RST);
- EADC_Open(EADC, EADC_CTL_DIFFEN_DIFFERENTIAL);
- EADC_ConfigSampleModule(EADC, 0, EADC_SOFTWARE_TRIGGER, 0);
- //EADC_CLR_INT_FLAG(EADC, EADC_STATUS2_ADIF0_Msk);
- //EADC_ENABLE_INT(EADC, BIT0);
- //EADC_ENABLE_SAMPLE_MODULE_INT(EADC, 0, BIT0);
- }
- //---------------------------------------------------------------
- 跟ADC读取函式
- uint16_t Get_ADC_VAL()
- {
- uint16_t vol=0;
- EADC_START_CONV(EADC, BIT0);
- //while (EADC_GET_INT_FLAG(EADC, BIT0) == 0);修改为:
- while(EADC_GET_DATA_VALID_FLAG(EADC, BIT0) != BIT0);
- vol = EADC_GET_CONV_DATA(EADC, 0);
- EADC_CLR_INT_FLAG(EADC, BIT0);
- return vol;
- }
复制代码
|