2011-05-21 06:40 AM
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 Nick2011-05-22 07:07 PM
I've tested here, for me the debug shows 0x0F (00001111b). Looking the PE_IDR register.
2011-05-22 07:56 PM
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);
2011-05-22 11:54 PM
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...2011-05-23 12:06 AM
You might want to try
PortEValue = GPIOE->IDR; or PortEValue = (u8)(GPIOE->IDR);2011-05-23 07:11 AM
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.
2011-05-23 07:35 AM
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.
jdf2011-05-24 06:29 AM
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!)2011-06-01 02:53 AM
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