- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using 'cy8c4247lqi'. I am i am trying to interface fingerprint sensor over the uart.
My sensor can understand only HEX. Problem is i can sent Only String and char. by usinguartputstring() and uartputchar() but is is acsii value.
Please anyone guide me how to send and receive HEX in Uart.
Thanx
Dharmesh
Solved! Go to Solution.
- Labels:
-
BLE
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hex data contains 0x00 which is used as string terminator. This prohibits the use of putstring().
PutChar() will send a 0x00 over the UART line, so using this API you will perform what you need to.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hex data contains 0x00 which is used as string terminator. This prohibits the use of putstring().
PutChar() will send a 0x00 over the UART line, so using this API you will perform what you need to.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanx Bob for your reply.
I am using,
UART_UartPutChar(0x02); //STX
ch = UART_UartGetChar();
UART_UartPutChar(ch);
UART_UartPutChar(0x00u); //LSB
ch = UART_UartGetChar();
UART_UartPutChar(ch);
UART_UartPutChar(0x00u); //MSB
ch = UART_UartGetChar();
UART_UartPutChar(ch);
UART_UartPutChar(0xD2u); //DATA
ch = UART_UartGetChar();
UART_UartPutChar(ch);
UART_UartPutChar(0x00u); //PLB
UART_UartPutChar(0x00u); //PLB
This code to send 02 00 00 D2 00 00 to my sensor. For cross checking i am trying to recive the same char. i have sent. But every time i am reciveing only first element E.X putcahr(0x02) send 0x02 and ch = getchar(); should recive 0x02 but ch is = 0 .
I am doing any mistake here??
please help me. I can able to recive data which is sent bt key board i have problem with only hex values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Try reading back multiple values from the UART after sending the HEX data to verify it isn't an issue with response data being stuck in a buffer (FIFO hardware or software Circular buffer).
Double check your UART transmission speeds match between the devices as well, mismatched speeds will have interesting data exchanges 🙂
Try checking the RX size to see how many received data bytes are stored, as there could be more than one stored, with 0 being a byte from some previous spurious response data.