The API for UART (v1.20) contains a bug in UART_GetByte().
This function is intended to return status in the MSB of a 16-bit unsigned int.
However, the compiler for PSoC3 does not generate the intended code for the expression:
return ( (UART_1_RXSTATUS << 8) | UART_1_ReadRxData());
The result is computed as an 8-bit quantity before type promotion to the 16-bit return value.
Thus the MSB is always returned as zero (in R6), as the assembly output listing shows:
C51 COMPILER V8.16 UART_1 04/21/2010 23:26:48 PAGE 34
0000 120000 R LCALL UART_1_ReadRxData
0003 90646C MOV DPTR,#0646CH
0006 E0 MOVX A,@DPTR
0007 FE MOV R6,A
0008 7E00 MOV R6,#00H
000A EF MOV A,R7
000B 4E ORL A,R6
000C FF MOV R7,A
000D 7E00 MOV R6,#00H
000F 22 RET
Construction of a 16-bit result from two 8-bit parts is a generic problem which requires use of a construct such as the Windows MAKEWORD macro to typecast the bytes before use:
#define MAKEWORD(lo,hi) ((WORD)((((WORD)(hi)) << 8) | ((BYTE)(lo))))
return MAKEWORD(UART_1_RXSTATUS, UART_1_ReadRxData());
Good catch. This bug is fixed in UART component ver.1_50 which is available with PSoC Creator Beta5.