- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Friends,
How can I send character until there's response ?
I wanna keep sending "UART_1_PutChar(0x01);" until there's response,
Anyone has idea for it ?
Thank you
Here's the code :
UART_1_PutChar(0x01);
Delay10msTimes(50);
c = UART_1_cGetChar();
if (c == 0x01)
{
UART_1_CPutString("Char 0x01 accepted!");
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Card in ");
}
else
if (c == 0xFE)
{
UART_1_CPutString("Char 0xFE accepted!");
LCD_clr_line(0);
LCD_clr_line(1);
LCD_1_Position(0,0); // Set LCD position
LCD_1_PrCString("Card out ");
}
- Labels:
-
PSoC 1
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I got the answer, make the delay faster,
do {
UART_1_CmdReset(); // Reset Command Buffer
for (i=0;i<10;i++)
{
UART_1_PutChar(0x01); //give command to the reader
Delay50uTimes(1);
}
c = UART_1_cGetChar();
}while (c == 0);
And how can I get multiple char ?
thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I want to send AB 02 01 and get the result AB 04 01 04 00,
How can I do that ?
Here's the datasheet...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Is it possible for me doing like this ? I wanna take the first char from total five characters ...
do {
UART_1_CmdReset(); // Reset Command Buffer
for (i=0;i<2;i++) //repeat command 15 times
{
for (i=0;i<3;i++)
{
UART_1_PutChar(sel_card); // Send a character to UART TX port
}
Delay50uTimes(1);
}
c = UART_1_cGetChar();
}while (c == 0);
byte_length = UART_1_cGetChar();
for (i=0;i<byte_length;i++)
{
RxdataBuff = UART_1_cGetChar(); // Get a character from UART RX data register
}
if (RxdataBuff[0] == 0xAB) //check the first character
{
switch(RxdataBuff[1]) // Check status byte
{
case 0x04: // If 0x04 : Operation success
LCD_clr_line(0); //clear LCD screen
LCD_clr_line(1);
LCD_1_PrCString("Card Selected"); // Print "Card selected" on the LCD ;
LCD_1_Position(1,0);
LCD_1_PrCString("SN: ");
for (i=2;i<6;i++)
{
LCD_1_PrHexByte(RxdataBuff); // Print serial number of the card detected
}
break;
case 0x02: // If 0x02 : Operation fail
LCD_clr_line(0); //clear LCD screen
LCD_clr_line(1);
LCD_1_PrCString("Operation failed"); // Print "Card selected" on the LCD ;
break;
}//end switch
}//end if