cancel
Showing results for 
Search instead for 
Did you mean: 

test on the value of a vector

nad
Associate II
Posted on December 30, 2010 at 00:13

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;

   

10 REPLIES 10
Andrew Neil
Evangelist III
Posted on January 08, 2011 at 18:14

''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...