cancel
Showing results for 
Search instead for 
Did you mean: 

GPIO inactive

blazevic
Associate II
Posted on March 02, 2016 at 15:43

Hello after trying myself and researching eventual similar problems I'm still facing a wall.

I'm using a Nucleo F401RE and can't seem to get anymore GPIO functioning. I'm out of clues now. Here is my set up:

-Connected and ILI9341 on SPI1 (SCK-->D13; MISO-->D12; MOSI-->D11; CS-->D13; D/C--> D9) Working fine with baud rate prescaler 0;

-Using ADC1(the only one actually) on channel 1 (GPIOA Pin 1) seems fine with me

I'm now trying to drive a 4wire resistive screen but I can't get any GPIO(PortAor B) working on top of what I already have.

So first step set current across an axis=> Put PA0 High and an other one low.

I'm checking PA0 with the ADC (Zin=50k so I doubt it's because i'm drawing too much current since limit is 25ma for any I/O) and all I get is noise oscillating around 450mV  (Vref=VDD=3.3  and ADC 12b reading around 560).

Here is the chunk of code I'm using ( right after System init or in a separate function called in the main loop later doesn't seem to change anything)

 RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);

     GPIO_InitTypeDef GPIOstruct1;

     GPIOstruct1.GPIO_Pin=0;

     GPIOstruct1.GPIO_Mode=GPIO_Mode_OUT;

     GPIOstruct1.GPIO_OType=GPIO_OType_PP;

     GPIOstruct1.GPIO_Speed=GPIO_Speed_25MHz;

     GPIOstruct1.GPIO_PuPd=GPIO_PuPd_NOPULL;

     GPIO_Init(GPIOA,&GPIOstruct1);

     GPIO_SetBits(GPIOA,GPIO_PIN_0);

I've also checked my clocks and although it seems to think it's using HSE (with no X3) and get sysclk running at 168MHz) I can get GPIOs alone working with the same config on a separate simple example.

My question being: Is it because i'm already using the PORT A for SPI and ADC and B for SPI only? 

If anyone has an answer or even just a hint for investigation I'll be grateful! 

Thank you
4 REPLIES 4
John F.
Senior
Posted on March 02, 2016 at 16:34

Check the pin definition for

GPIOstruct1.GPIO_Pin=0;

Perhaps you should be usingGPIO_Pin_0 whose value may not be zero!
blazevic
Associate II
Posted on March 02, 2016 at 17:47

Still can't believe I've missed that! any tips on avoiding noise ?

For the Touch X coordinate i'm using this method.

X+ --> VDD

Y+ --> ADC

X- --> GND

Y- --> don't know what to do with that one and it generates a lot of noise 

But I REALLY can't believe I've missed that!

John F.
Senior
Posted on March 03, 2016 at 09:03

You don't say what touch screen you're using. Just googling ''4 wire resistive screen'' and ''f401re touch screen'' brings up interesting links. You can average multiple readings to reduce noise of course. Depends on the speed of response and accuracy you need to achieve.

blazevic
Associate II
Posted on March 16, 2016 at 02:43

Thanks John. I simply solved it with a decoupling capacitor, I found from old TV scraps i found in the street, on those unused pins. All the solutions I found on internet used a controller with I2C com.

Thanks for feedback!