-
1. Re: uart in CY8C4247LQI-BL483
user_1377889 May 15, 2017 3:06 AM (in response to rushinthakkar_1532111)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
-
2. Re: uart in CY8C4247LQI-BL483
rushinthakkar_1532111 May 15, 2017 3:39 AM (in response to rushinthakkar_1532111)hello thanks, i have uploaded code here. in this code, i am writing UART_UartPutChar(0xAA). so i should get 01000001 01000001. but i am getting 10101010.
-
code.zip 7.9 MB
-
-
3. Re: uart in CY8C4247LQI-BL483
user_242978793 May 15, 2017 6:22 AM (in response to rushinthakkar_1532111)Rushin your received signal is AA 10101010=AA why do you think it should be 01000001 01000001?
-
4. Re: uart in CY8C4247LQI-BL483
rushinthakkar_1532111 May 15, 2017 6:25 AM (in response to rushinthakkar_1532111)it should be ascii value of AA= 4141. 01000001 01000001
-
5. Re: uart in CY8C4247LQI-BL483
user_242978793 May 15, 2017 7:04 AM (in response to rushinthakkar_1532111)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.
-
6. Re: uart in CY8C4247LQI-BL483
user_242978793 May 15, 2017 7:46 AM (in response to rushinthakkar_1532111) -
7. Re: uart in CY8C4247LQI-BL483
e.pratt_1639216 May 15, 2017 7:47 AM (in response to rushinthakkar_1532111)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
-
8. Re: uart in CY8C4247LQI-BL483
user_242978793 May 15, 2017 8:00 AM (in response to rushinthakkar_1532111)You should check out this Printf instructions it may help you.
-
printf[1]2.pdf 81.5 K
-
-
9. Re: uart in CY8C4247LQI-BL483
rushinthakkar_1532111 May 16, 2017 6:00 AM (in response to user_242978793)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[i]);
} -
10. Re: uart in CY8C4247LQI-BL483
user_242978793 May 16, 2017 8:00 AM (in response to rushinthakkar_1532111) -
11. Re: uart in CY8C4247LQI-BL483
rushinthakkar_1532111 May 16, 2017 8:05 AM (in response to rushinthakkar_1532111)it works fine. but when i am writing array like UART_UartPutChar(command[i]); then its not working for me
-
12. Re: uart in CY8C4247LQI-BL483
user_242978793 May 16, 2017 8:25 AM (in response to rushinthakkar_1532111)worked here no issue I'll send the program with your code added. The for loop runs continuously so you will need to modify it.