uart in       CY8C4247LQI-BL483

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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??

0 Likes
12 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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.

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Rushin your received signal is AA 10101010=AA why do you think it should be 01000001 01000001? 

0 Likes
Anonymous
Not applicable

it should be ascii value of AA= 4141.   01000001 01000001

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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.

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

Here is an example program that echo's what you type on the terminal .

   

0 Likes
Anonymous
Not applicable

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

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

You should check out this Printf instructions it may help you.

0 Likes
Anonymous
Not applicable

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);
        }

0 Likes
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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.

   

0 Likes
Anonymous
Not applicable

it works fine. but when i am writing array like UART_UartPutChar(command); then its not working for me

0 Likes
lock attach
Attachments are accessible only for community members.
rola_264706
Level 8
Level 8
50 likes received 25 likes received 10 likes received

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.

0 Likes