I'm trying to interface a 4-wire resistive touchscreen to a STM32F429 Discovery board but I can't figure out how it works. I want the MCU to detect a touch so I configured the 4 pins like this:
X+ --> input w/pullup connected to EXTI external interrupt X- --> input floating (tristated) Y+ --> input floating (tristated) Y- --> output to GND
in this configuration I should be able to detect a touch and trigger an interrupt on the EXTI line so I can enter a ISR and sample the x and y values with the ADC. But when I connect the X- pin the X+ pin goes to near GND. It seems like current flows between X+ and X- (so the X- is not tristated?). Here's the code I use to configure the GPIO pins:
GPIO_InitTypeDef gpio; gpio.Pin = GPIO_PIN_2 | GPIO_PIN_1; gpio.Mode = GPIO_MODE_INPUT; gpio.Pull = GPIO_NOPULL; HAL_GPIO_Init(GPIOA, &gpio); gpio.Pin = GPIO_PIN_0; gpio.Mode = GPIO_MODE_INPUT; gpio.Pull = GPIO_PULLUP; HAL_GPIO_Init(GPIOA, &gpio); gpio.Pin = GPIO_PIN_5; gpio.Mode = GPIO_MODE_OUTPUT_PP; HAL_GPIO_Init(GPIOA, &gpio); HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, GPIO_PIN_RESET); /* initialization using registers, works the same as above */ // /* Xr and Yu open (input floating) */ // GPIOA->MODER &= ~(GPIO_MODER_MODE2 | GPIO_MODER_MODE1); // GPIOA->PUPDR &= ~(GPIO_PUPDR_PUPD2 | GPIO_PUPDR_PUPD1); // // /* Xl input with pull-up */ // GPIOA->MODER &= ~GPIO_MODER_MODE0; // GPIOA->PUPDR |= GPIO_PUPDR_PUPD0_0; // // /* Yd to GND (output set to 0) */ // GPIOA->MODER |= GPIO_MODER_MODE5_0; // GPIOA->ODR &= ~GPIO_ODR_OD5;
I can't understand what I am doing wrong or how to configure the tristated pins correctly so they don't pull down the X+ pin.