Use GPIO and ADC function at once

cancel
Showing results for 
Search instead for 
Did you mean: 

Use GPIO and ADC function at once

301 Views
anujtanksali
Contributor II

Hello,

Am using iMXRT1064 device and a 4 wire touch screen signals X+, X- , Y+ and Y- are interfaced to the micro controller.

The requirement is we should be able X+ and Y+ as gpio as well as ADC input

for example to use X+ as GPIO as well as ADC signal using MCU Xpresso as IDE config tools am configuring GPIO_AD_B0_14 pin for X+ signal as below

pastedImage_1.png

I have selected both functions ADC1_IN3 and GPIO1_IO14 as i have to used the pin as gpio as well as ADC pin.

is this configuration correct?

if yes then while setting the pin as output am using 

gpio_pin_config_t config= {

.direction = kGPIO_DigitalOutput,
.outputLogic = 0U,
.interruptMode = kGPIO_NoIntmode
};

GPIO_PinInit(BOARD_INITPINS_TOUCH_XL_DIO_GPIO,BOARD_INITPINS_TOUCH_XL_DIO_PIN,&config) 

GPIO_PinWrite(BOARD_INITPINS_TOUCH_XL_DIO_GPIO, BOARD_INITPINS_TOUCH_XL_DIO_PIN, 1)

and while using the pin as ADC input i have to set the pin as input and then read the ADC peripheral ADC1 and channel 3

config.direction = kGPIO_DigitalInput 

GPIO_PinInit(BOARD_INITPINS_TOUCH_XL_DIO_GPIO,BOARD_INITPINS_TOUCH_XL_DIO_PIN,&config) 

config the ADC structures to use ADC1 and channel 3 and trigger a ADC conversion

is my understanding correct?

Please let me know the correct method to use the pin as GPIO as well as ADC input.

Thanks,

Regards

Anuj

Labels (1)
Tags (1)
0 Kudos
3 Replies

248 Views
FelipeGarcia
NXP TechSupport
NXP TechSupport

Hi Anuj,

 

This configuration is not correct. You should only mux 1 of all the alternatives for each pin.

 

Best regards,

Felipe

0 Kudos

248 Views
anujtanksali
Contributor II

Hi felipegsoto‌,

Thanks for the reply,

Initially if i config the pin as gpio then how will i be able to use the same pin for ADC function?

if i configure the gpio pin as input and read ADC value from that pin by configuring ADC channel as per pin then will it work? 

Thanks

Regards,

Anuj

0 Kudos

232 Views
FelipeGarcia
NXP TechSupport
NXP TechSupport

Hi Anuj,

You will only be able to use the same pin for ADC if you reconfigure it to ADC alternative back and forth but we do not recommend it. Otherwise it will not work.

Best regards,

Felipe

0 Kudos