Hello everyone, I want to use IF statement to check the data read in by USART, and according the data to do different things. But it seems like the If statement doesn't work at all.
I am using RS232 to transmit data to Atmega48, I do have a chip to convert the voltage between uC and RS232.
the code:
unsigned int info;
while(1)
{
info = USART_Receive();// say info == 0b1010XXXX;
if((info >> 4) == 10)//ater right shift info ==0b00001010, which = 10
{
LED_ON;
}
USART_Write(info);// I can observe the "info" here to make sure the data //is correct.
}
the LED never lights up, I only send the data to uC once, so the infinite loop must be hold by the USART_Receive(); function after first data entered.
I am using RS232 to transmit data to Atmega48, I do have a chip to convert the voltage between uC and RS232.
the code:
unsigned int info;
while(1)
{
info = USART_Receive();// say info == 0b1010XXXX;
if((info >> 4) == 10)//ater right shift info ==0b00001010, which = 10
{
LED_ON;
}
USART_Write(info);// I can observe the "info" here to make sure the data //is correct.
}
the LED never lights up, I only send the data to uC once, so the infinite loop must be hold by the USART_Receive(); function after first data entered.
Last edited: