- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello there i am using CY8C4247LQI-BL483.
In uart, i know that ascii value are transmitted like. if i transmit 'A', then it will transmit 0x41.
can you tell me how to do this in cypress uart?
there are two functions for it.
(1) UART_UartPutChar
(2) UART_UartPutString
like i have
uint8_t tx_data[2] ={0xAA}
UART_UartPutChar(tx_data[0])
but its not working for me.
can you tell me solution??
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
PutChar() sends a single character to UART while PutString() sends a null-terminated string of arbitary length to the interface.
In your example UART_UartPutChar(tx_data[0]) I cannot see any initialization for tx_data[0].
Can you please post your complete project or a shortened version that shows the error so that we all can have a look at all of your settings. To do so, use
Creator->File->Create Workspace Bundle (minimal)
and attach the resulting file.
Bob
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rushin your received signal is AA 10101010=AA why do you think it should be 01000001 01000001?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it should be ascii value of AA= 4141. 01000001 01000001
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Rushin 0XAA is not ascii AA it is DEC 170 or bin 10101010 your returned value is 100000101000001 that is hex 4141 or 16705 dec. You need to define that data as char. I'll check your program for more information.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
UARTPutChar() will only put a single ASCII character (or one byte) of data into the UART buffer; In order to write the ASCII sequence "AA", you would want to call it twice like this:
UART_UartPutChar('A');
UART_UartPutChar('A');
Note: 0xAA gives the binary value: 10101010 as a single byte binary value.
'A' on the other hand gives: 01000001 as a single byte binary value.
The syntax is different when working with binary, hexadecimal, and ascii.
binary begins with 0b followed by 8 ones or zeroes.
hexadecimal is 0x followed by two alphanumerics: 0-9,A-F as valid characters
ascii is just the visible character you want to write inside single quote marks: 'A' or 'B' etc.
'A' = 0x41 = 0b01000001,
ASCII vs Hexadecimal vs Binary
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
hi bob thanks for your support. i understand it.
i want to send command
0x55, 0xAA, 0x01, 0x00,0x01,0x00,0x00,0x00,0x12,0x00,0x13,0x01
so i am writing code like
UART_UartPutChar(0x55);
UART_UartPutChar(0xAA);
UART_UartPutChar(0x01);
UART_UartPutChar(0x00);
UART_UartPutChar(0x01);
UART_UartPutChar(0x00);
UART_UartPutChar(0x00);
UART_UartPutChar(0x00);
UART_UartPutChar(0x12);
UART_UartPutChar(0x00);
UART_UartPutChar(0x13);
UART_UartPutChar(0x01);
it works fine.
but for this syntax its not working for me
uint8_t command[12] ={0x55,0xAA,0x01,0x00,0x01,0x00,0x00,0x00,0x12,0x00,0x13,0x01};
for(i=0; i<12; i++)
{
UART_UartPutChar(command);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I changed your characters to ASCII hex codes so I could read them and it worked fine. . I don't know what you are feeding them too but it may be a timing issue. You maybe feeding it too fast for the device to respond to the input.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
it works fine. but when i am writing array like UART_UartPutChar(command); then its not working for me
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content