Some GPIO Pins does not work in STM32VLDiscovery
You have two lines of code where you set GPIOB-&gt;CRH:

GPIOB-&gt;CRH   &amp;= ~BIT2 &amp;&amp; ~BIT3;

GPIOB-&gt;CRH   &amp;= ~BIT6 &amp;&amp; ~BIT7;


The &amp;&amp; operator is the logical AND, which returns true or false. What you need to use here is the &amp; operator, which is the bitwise AND.

The same applies to the logical OR operator || and the bitwise OR | in the other lines of code.