GPIO initialization/testing
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-12-22 2:02 PM
Posted on December 22, 2010 at 23:02
hello,
I just started with the STM8S-discovery .
can you tell me how I boot the pine 0,1,2 port B as input.
and how I'm doing the test on the value entered.
if (?????)
{
instruction 1....
}
This discussion is locked. Please start a new topic to ask your question.
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-12-23 2:50 AM
Posted on December 23, 2010 at 11:50
i.e. for PORTC pin 0:
#define BUTTON_PORT (GPIOC) #define BUTTON_PIN (GPIO_PIN_0)/* -------------------------------------------------------------*/
/* Check button status */ if ((GPIO_ReadInputData(BUTTON_PORT) & BUTTON_PIN) == (u8)0x00) { /* Button is pressed */ ..... ..... } by default all ports are configured as input floating. If you want you can configure them as input pull up at the beginning before doing the check on pin port status: /* Initialize I/O in Input Mode with pull up and no interrupt*/ GPIO_Init(BUTTON_PORT, BUTTON_PIN, GPIO_MODE_IN_PU_NO_IT); I suggest you to configure it as input pull up so when button is not presd pin0 is high, when you press button pin0 is low. brazov2Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
‎2010-12-29 2:05 PM
Posted on December 29, 2010 at 23:05
sorry, I made a mistake with the pines.
it works now
thank you
