Hey -
wondering if you see something obvious wrong with my code:
My intention - within my Receive ISR - I set a variable: comm_reception = 1; (clear it elsewhere)
I am having a problem getting into the if statement looking for comm_reception.
I placed a printf statement just before that if statement to print that value of comm_reception. - with that printf statement in the code - it works - it should that when I would send a character - comm_reception is a "1"
The printf statement is:
printf("Comm_Received = %d\n",comm_reception);
when I comment out the statement I do not get into the if statement
I don't see it -
???
Thanks
Sparky
code is below:
wondering if you see something obvious wrong with my code:
My intention - within my Receive ISR - I set a variable: comm_reception = 1; (clear it elsewhere)
I am having a problem getting into the if statement looking for comm_reception.
I placed a printf statement just before that if statement to print that value of comm_reception. - with that printf statement in the code - it works - it should that when I would send a character - comm_reception is a "1"
The printf statement is:
printf("Comm_Received = %d\n",comm_reception);
when I comment out the statement I do not get into the if statement
I don't see it -
???
Thanks
Sparky
code is below:
Rich (BB code):
int main(void)
{
init_io_ports();
init_comm_port();
/* set up serial printing */
fdevopen(uart_putchar,NULL);
sei();
printf("System 2 Ready ...\n");
for(;;)
{
loop_counter++;
printf("Comm_Received = %d\n",comm_reception);
if(comm_reception == 1)
{
printf("here\n");
if(receive_character == '2')
{
printf("2 Listening\n");
talking_to_me = 1;
comm_reception = 0;
}
if(talking_to_me == 1 && receive_character == 'o')
{
printf("2 On\n");
talking_to_me = 0;
comm_reception = 0;
talking_to_me = 0;
}
if(talking_to_me == 1 && receive_character == 'f')
{
printf("2 Off\n");
talking_to_me = 0;
comm_reception = 0;
talking_to_me = 0;
}
if(talking_to_me == 1 && receive_character == 's')
{
printf("2 Status\n");
talking_to_me = 0;
comm_reception = 0;
talking_to_me = 0;
}
}
ISR(USART_RX_vect) //COMM RECEIVER Interrupt
{
receive_character = UDR0;
// if(Comm_Test_Running == 1)
// {
//printf("Character Received = %c\n",receive_character);
// }
comm_reception = 1;
key_pressed = 1;
}
Last edited by a moderator: