This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

ADC data of those ADC input pins which can also be used as GPIO are incorrect

I tested on my f28p55x control card and found some pins' ADC data are incorrect, while some other pin's ADC data are correct.

Further investigation found the ADC data of those ADC input pins which can also be used as GPIO are incorrect, such as below:

  • A16/GPIO28
  • A17/GPIO20
  • A10/GPIO230

while the ADC data of those ADC input pins which can NOT be used as GPIO are correct, such as below:

  • A0
  • A14
  • A15

I then configured Pin A10/GPIO230 as "GPIO_DIR_MODE_IN " like below:

GPIO_setDirectionMode(230, GPIO_DIR_MODE_IN);
GPIO_setQualificationMode(230, GPIO_QUAL_SYNC);
//GPIO_setPinConfig(GPIO_230_GPIO230);

but ADC data of Pin A10 are still incorrect.

I guess I can not configure Pin A10 as GPIO? Could you advise how to configure  Pin A10 as ADC input pin ONLY to have correct ADC data? Some code snippet would be very helpful.

  • Quentin,

    Inside gpio.c file there is a function called GPIO_setAnalogMode(uint32_t pin, GPIO_AnalogMode mode),  where you pass it the pin number(for instance GPIO28) and the define "GPIO_ANALOG_ENABLED" if you want to use the pin as an ADC(or other analog function).

    These pins are what we call "AGPIO" and since the use case of each system is unknown their reset state is "unconfigured" meaning that until this function is call they will not work as analog or digital pin.  If you wanted to use the pin as a GPIO you would pass the define GPIO_ANALOG_DISABLED

    Best,
    Matthew

  • Thanks, Matthew. Please close this case.