I am trying to implement a routine to assign the count of a rotary buffer count to an array element. The array element, command_buffer[1] is defined as an unsigned char and the function, get_sci_buffer_status returns an unsigned char. However, the assignment does not appear to work.
As the code below shows, I am trying to output the array element immediately after assignment.
Each time the CASE is called, the 'A' is sent out the SCI port, however, the "count" is never sent out. If I swap position of the 2 SCI outputs, I don't get anything on the SCI port.
I have also tried to output the contents of command_buffer[1] directly with the same results as above.
I do not understand why this assignment does not work. Any suggestions will be greatly appreciated. Code fragment is shown below. Also, I do not have access to the monitor to debug this correctly. That is why I am using the SCI to output variables.
CODE FRAGMENT
// returns 0 if no data in sci_buffer else retuns data count in buffer
case CMD_GET_SCI_STATUS: {
unsigned char count = get_sci_buffer_status();
command_buffer[1] = get_sci_buffer_status(); // this is the line I need to work, the rest is debug
if (SCS1 & SCS1_SCTE_MASK) {
SCDR = 'A';
}
while (~(SCC1& SCS1_SCTE_MASK));
if (SCS1 & SCS1_SCTE_MASK) {
SCDR = count;
}
return (1);
}