AnsweredAssumed Answered

ADC callback for KE02

Question asked by Adam Zhou on Feb 4, 2017
Latest reply on Feb 14, 2017 by Adam Zhou

I want to read values from the multiple ADC channels in interrupt mode. From the kexx_drv_lib, ADC_SetCallBack() sets the callback function and ADC_SetChannel() sets ADC channel. Can I set the multiple channels and then know which channel the value with ADC_ReadResultReg() is from in callback function?

 

Code example:

...

    ADC_SetCallBack(ADC_CallBack);
    ADC_Init(ADC, &sADC_Config);

    ADC_SetChannel(ADC,ADC_CHANNEL_AD2)

    ADC_SetChannel(ADC,ADC_CHANNEL_AD3)

    ADC_SetChannel(ADC,ADC_CHANNEL_AD4)

...

void ADC_CallBack( void )

{

    //Which ADC channel is this result from? Any function can be used?

    uint16_t result = ADC_ReadResultReg(ADC);

}

Outcomes