2010-12-29 03:13 PM
Hello,
I want to write a program to make his test on the value of a vector.
is that there is another simpler solution??
GPIO_DeInit(GPIOB);
GPIO_Init(GPIOB, GPIO_PIN_0, GPIO_MODE_IN_PU_NO_IT);
GPIO_Init(GPIOB, GPIO_PIN_1, GPIO_MODE_IN_PU_NO_IT);
GPIO_Init(GPIOB, GPIO_PIN_2, GPIO_MODE_IN_PU_NO_IT);
if (((GPIO_ReadInputData(GPIOB) & GPIO_PIN_0)== 0)) &(((GPIO_ReadInputData(GPIOB) & GPIO_PIN_1)== 0))&
(((GPIO_ReadInputData(GPIOB) & GPIO_PIN_2)== 1))
{
//do operation 1;
}
else
if (((GPIO_ReadInputData(GPIOB) & GPIO_PIN_1)== 0)) &(((GPIO_ReadInputData(GPIOB) & GPIO_PIN_1)== 0))&
(((GPIO_ReadInputData(GPIOB) & GPIO_PIN_2)== 1))
{
// do operation 2;
}
........
........
........
........
else
operation n;
2011-01-08 09:14 AM
''I connected a sensor to port B which gives a value of 5 bit''
So what is connected to the other 3 bits of the port? Unless you are absolutely certain that they are - and always will be - guaranteed to be zeros, you need to ''mask-out'' those other bits...