I am trying to get a 2 character string into my program in order to then determine a command based on the string. This is in an embedded application.
Right at the top of my program I have declared
static char comin[3]; // declared as 'static' - I will use it in a number of places
.
.
.
void main ()
{
//process comin here and execute command based on string in comin
}
//here is the isr that goes and fetches the string from the serial port
void uart_rx_isr (void) interrupt 4 using 3
{
EA=0; // disable interrupts while this one is serviced
gets(comin,3);
EA=1; //re-enable interrupts
}
I am using a Keil compiler
gets() supposed to take in 3 chars and then exit, or, if it encounters a \n before 3 chars, it is supposed to terminate. It replaces \n with a null ('0').
However, when I look at the contents of comin in the simulator, all values are 0 and the program hangs in the interrupt service routine - it just sits there.
I think I am doing something wrong with my pointers or array wrt comin.
Can someone point me the right direction here?
Appreciate your help.
Right at the top of my program I have declared
static char comin[3]; // declared as 'static' - I will use it in a number of places
.
.
.
void main ()
{
//process comin here and execute command based on string in comin
}
//here is the isr that goes and fetches the string from the serial port
void uart_rx_isr (void) interrupt 4 using 3
{
EA=0; // disable interrupts while this one is serviced
gets(comin,3);
EA=1; //re-enable interrupts
}
I am using a Keil compiler
gets() supposed to take in 3 chars and then exit, or, if it encounters a \n before 3 chars, it is supposed to terminate. It replaces \n with a null ('0').
However, when I look at the contents of comin in the simulator, all values are 0 and the program hangs in the interrupt service routine - it just sits there.
I think I am doing something wrong with my pointers or array wrt comin.
Can someone point me the right direction here?
Appreciate your help.
Comment