2009-01-04 09:18 PM
2011-05-17 12:55 AM
I AM TRYING TO READ SOME SWITCHES WITH GPIO6 AND GPIO1.
MY CONFIGURATION IS: GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Disable; GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector; GPIO_Init (GPIO1, &GPIO_InitStructure); AND GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1 | GPIO_Pin_2 | GPIO_Pin_3 |GPIO_Pin_4 | GPIO_Pin_5 | GPIO_Pin_6 | GPIO_Pin_7; GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Disable; GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector; GPIO_Init (GPIO6, &GPIO_InitStructure); BUT I AM NOT ABLE TO READ THE PINS PROPERLY, THERE ARE PULLUP'S ON ALL THE PINS AND THE SWITCH GROUNDS THE PIN. WHEN SYSTEM IS POWERED ON, PINS READ HIGH, BUT IF I PRESS ANY SWITCH AND THEN AGAIN OPEN IT, THAT PIN REMAINS LOW, I HAVE ALSO CHECKED THIS WITH A CRO. THE SIGNAL ON THE PIN GOES LOW PERMANENTLY EVEN IF THE PULL UP IS THERE AND THE SWITCH IS OPEN. PLEASE HELP. THANKS.2011-05-17 12:55 AM
Did you enable the clocks to your peripheral ?
SCU_APBPeriphClockConfig(__GPIO6 ,ENABLE); SCU_APBPeriphReset(__GPIO6,DISABLE); SCU_APBPeriphClockConfig(__GPIO1 ,ENABLE); SCU_APBPeriphReset(__GPIO1,DISABLE);2011-05-17 12:55 AM
offcourse the clocks are enabled.
2011-05-17 12:55 AM
Sounds frustrating.
Have you tried halting the ARM with a breakpoint before anything is initialized, and then confirming with a scope that the voltage on the pin behaves properly when the switch is toggled? If that works, try moving the configuration if just those pins to the first step in your init routine. Try calling GPIO_DeInit & GPIO_StructInit before setting up this pins just to eliminate any loose ends. Put a couple of read instructions right after the initialization steps and try reading different switch states between breakpoints. If that works I would suspect something funny in the remainder of your init routine... I have seen others do lots of cut & paste and forget to change port or pin numbers. I've also seen cases where not all fields are set for the initstruct and a pin will 'inherit' an incorrect setting for values above it. Again, these are just guesses since I can't see your the rest of your code. If this doesn't work, you might have to start checking for shorts or something less pleasant.2011-05-17 12:55 AM
What is the IDE you are using? If you are using crossworks, and with one of the debug projects, it may be screwing up the library. If you are using crossworks, set the properties to UNDEFINE DEBUG - that should do the trick (assuming that its what you are using).
2011-05-17 12:55 AM
Hi,
You should set all outputs of that GPIO to '1' before you can read the input pins. Luc2011-05-17 12:55 AM
Hello satnam.singh!
i´ve the same problem with Port 6! When the Port a ''Low'' level hat I can not read any ''High'' level more. How did you solve your problem? Here is my code: GPIO_DeInit(GPIO6); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_All; GPIO_InitStructure.GPIO_Direction = GPIO_PinInput; GPIO_InitStructure.GPIO_Type = GPIO_Type_OpenCollector; GPIO_InitStructure.GPIO_IPInputConnected = GPIO_IPInputConnected_Disable; GPIO_InitStructure.GPIO_Alternate = GPIO_InputAlt1; GPIO_Init(GPIO6, &GPIO_InitStructure); GPIO_Write(GPIO6, 0xFF); test=GPIO_Read(GPIO6); Thanks!