AnsweredAssumed Answered

>> or & operators

Question asked by Jalal Sadigli on May 9, 2017
Latest reply on May 10, 2017 by Clive One

hi

 

this code which i use >> (shift operator) to detect flag work correctly

void putchar( char *string)
{

while(*string)
{
while(usart_sr >> 6 == RESET);
while(usart_sr >> 7 == RESET);
USART_SendData(USART2,*string);
*string++;
}
}

but when i change it from & and some value of hex, the does not work correctly

void putchar( char *string)
{

while(*string)
{
while(usart_sr & 0x80 == RESET);
while(usart_sr & 0x40  == RESET);
USART_SendData(USART2,*string);
*string++;
}
}

is there someone to explain why?

 

thanks

Outcomes