|
Debugging communication software is not easy without ICE and CRO.
As others suggest get an ICE or/and a CRO.
for the time being.
void main (void)
{
usinged char ucResponse = 0;
/***
all other program to initalize the UART here
***/
whie (1)
{
ucResponse = 0;
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Sending 0x01");
do {
UART_1_PutChar(0x01);
Delay10msTimes(50);
/* do a read char, if 0, send 0x01 again, else can start decode the reponse */
/* This is assuming RX to the UART is between 1 and 0xFF */
ucResponse = UART_1_cReadChar();
}while (ucResponse == 0);
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
if (ucResponse == 0x01)
{
LCD_1_PrCString("Card in ");
}
else
{
if (ucResponse == 0xFE)
{
LCD_1_PrCString("Card Not in ");
}
else
{
LCD_1_PrCString("Unknown response ");
}
}
/* Show the screen for 2 seconds */
Delay10msTimes(200);
}
|