2010-12-22 02:02 PM
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....
}
2010-12-23 02:50 AM
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. brazov22010-12-29 02:05 PM
sorry, I made a mistake with the pines.
it works now
thank you