cancel
Showing results for 
Search instead for 
Did you mean: 

[resolved] GPIO: Pull-up resistors on Port E

nholzem
Associate II
Posted on May 21, 2011 at 15:40

Hi all,

I've set PE0 -> PE3 as inputs with internal pull-up enabled.

Without connecting anything to these pins, I read the input register as 0x09, indicating that the pull-up is only operational on pins PE0 and PE3.

Has anyone noticed similar behavior?

Thanks and regards

Nick
8 REPLIES 8
fabioaymoto9
Associate II
Posted on May 23, 2011 at 04:07

I've tested here, for me the debug shows 0x0F (00001111b). Looking the PE_IDR register.

fabioaymoto9
Associate II
Posted on May 23, 2011 at 04:56

I'm testing the Input pins too. But when I tried to put the register value into a variable it shows me 0x00. In your example, setting the pin as input Pull Up and without anything connected at pin, I try to use the following code:

    

u8 PortEValue  =(u8)(GPIO_ReadInputPin(GPIOE,GPIO_PIN_0));

It returns zero. So I tried to read the PORTG->IDR directly:

    

PortEValue  = ((u8)GPIOE->IDR); //It also returned zero

The PortE IDR Register is showing the 0x0F value (Pins 0 to 3 are set).

I also tried: 

    

PortEValue  = GPIO_ReadOutputData(GPIOE);

Someone have any idea about this behavior?

Ps: I Initialized the pins as follow:

    

GPIO_Init(GPIOE, GPIO_PIN_0 , GPIO_MODE_IN_PU_NO_IT);  

    

GPIO_Init(GPIOE, GPIO_PIN_1 , GPIO_MODE_IN_PU_NO_IT);  

    

GPIO_Init(GPIOE, GPIO_PIN_2 , GPIO_MODE_IN_PU_NO_IT);  

   

GPIO_Init(GPIOE, GPIO_PIN_3 , GPIO_MODE_IN_PU_NO_IT);

nholzem
Associate II
Posted on May 23, 2011 at 08:54

Hi Fabio,

Thanks for your input.

Well I'm a bit confused.

I dont use the library.

I just wrote before the while(1)

GPIOE->DDR &= 0xF0;        // Set PE0 to PE3 as inputs

GPIOE->CR1 |= 0x0F;          // Set pull-up on PE0 to PE3  

Then i can measure the pins with a voltmeter and have 0V on PE1 and PE2. Alternatively, i can transfer GPIOE->IDR to a variable and read 0x09.

EDIT: i've added external pull-ups on these pins and now it's fine...

nholzem
Associate II
Posted on May 23, 2011 at 09:06

You might want to try

PortEValue  = GPIOE->IDR;

or 

PortEValue  = (u8)(GPIOE->IDR);

fabioaymoto9
Associate II
Posted on May 23, 2011 at 16:11

Hello Nico, yes I've tried these commands too. I discover the problem: For some way the compiler wasn't creating the local variable used for reading the pin or port. So using a global variable it worked. 

In your case, have you ever checked the FR6 option byte? This pins (PE1 and PE2) have alternate function i2C clk and data out. The problem could be in configuration of this byte. Your init function seems to be correct. I checked the ST library Init function and it follow the same steps. It only adds the line  GPIOE->CR2 &= 0xF0; for interrupt configuration. 

Regards.

jdf25252
Associate II
Posted on May 23, 2011 at 16:35

You're close!  The 2 pins used for the IIC interface are ''True Open Drain''  The pullups, Totem-Pole high driver and protection diodes are NOT implemented on those pins.  You need external pullups or totem pole drive for those 2 inputs.  AND, don't forget you'll need the external pullup for output uses too. I've been using ST7 & STM8 for years and I still get surprised more often then I'll admit.

jdf

nholzem
Associate II
Posted on May 24, 2011 at 15:29

Thanks John and Fabio! Your inputs are slightly conflicting but I appreciate your help! 🙂

@Fabio: Seems that AFR6 is useful for remapping port B. Looking at the option bytes, there's nothing related to port E. (NB i'm just starting with that uC!)

nholzem
Associate II
Posted on June 01, 2011 at 11:53

Hi all,

I got the input from the support guys and these 2 pins don't have the pull-up, there's a little mistake in the datasheet.

Thanks again for your interest in my little problem, and thanks a lot as well to the support guys who have been pretty responsive.

Regards

Nicolas