Uart RX PSoC3

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

cross mob
Anonymous
Not applicable

Good day

   

I've been trying to recieve data from pc hyperterminal but I don't understand how can I recieve more than one character

0 Likes
15 Replies
RaAl_264636
Level 6
Level 6
50 sign-ins 25 sign-ins 10 solutions authored

Hi jdbatista,

   

 

   

you should show your code.

   

In general, it's checking how many bytes are in the receive buffer, using this value as a loop counter and then reading out byte by byte until the loop has finished.

   

 

   

Regards,

   

 

   

Ralf

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

Since the UART sends and receives one byte at a time you have to retrieve your received message character by character. Depending on the way you use your UART there are different indicators for checking if a character is already received, in your buffer or in the FIFO. Have a deep look into the datasheet.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

There is an example project essentially doing this, character for character.

   

Goto "File", "Example Project" -

   

 

   

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Image did not post, now attached.

   

 

   

Also if connected to PC you must use a RS232 level translator, like

   

MAX232 or equivalent, to meet physical layer signaling voltages.

   

 

   

Regards, Dana.

0 Likes
HeLi_263931
Level 8
Level 8
100 solutions authored 50 solutions authored 25 solutions authored

Note that the -030 DevKit already has a level translator on board (see part 4.2.8 in the user guide).

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The -001 kit also has a RS232 transceiver.

   

 

   

Regards, Dana.

   

 

   

0 Likes
Anonymous
Not applicable

Well thanks for your answers, but recieving one character I understand until now, but at the time i wanna storage tha character follow by another characther is where I don't have idea how.

   

 

   

Thanks for your help

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

When you post your complete project here we all can have a look at and see where your problems are.

   

Use "Creator -> File -> Create Workspace Bundle (minimal)" and then attach the resulting file with your next reply (DO NOT use chrome, that does not work).

   

BTW: Are you using a development kit? Which one ??

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

The you would create a char array, a pointer into it, and as each char is received

   

its deposited into array and the pointer incremente to get ready for next char. When you

   

get to end of array reset ptr to beginning, this creates a circular buffer. If you are sending

   

a line terminated message, include code to deted EOL and act on it when it occurs.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

I'm really new with psoc so I have no reference about the pointer and array, do u have an example that I could use to understand hot to create the array and the pointer?

   

Thanks

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

This has nothing to do with PSoC, it is just C

   

 

   

#define NumberOfValues 2048

   

int16 ADCData[NumberOfValues];

   

int16 * ADCPointer;

   

// ...and later

   

ADCPointer = ADCData; // or

   

ADCPointer = &ADCData[0]

   

// You may write

   

ADCData[122] = 32767;

   

*ADCPointer[122] = 32767;

   

*(ADCPointer + 122) = 32767;

   

Here is a link to my favorite C-Manual publications.gbdirect.co.uk/c_book/

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

MytRxData[ 21 ] = "                    ";          // This clears array and its terminated by null character in 20'th position.

   

                                                                 // Remember this array address goes from 0 - 19, 20 is nul end of string terminator

   

 

   

unit8 pTr = 0;                                         // We will use this as array pointer

   

.char CharRecv = 0;

   

.

   

.

   

          for ( ;; ) {

   

                   CharRecv = UARgetdata (whatever name of function is( );

   

                   MyRxData[ pTr ] CharRecv;

   

                   pTr = ( pTr == 19 ) ? 0 : pTr + 1;        // Test for end of array, reset to 0 if it is

   

        }

0 Likes
Anonymous
Not applicable

Thanks Dana for your explanation, I really understand now how to point to an array

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

A couple of typo's in code, fixed here -

   

 

   

MytRxData[ 21 ] = "                    ";          // This clears array and its terminated by null character in 20'th position.

   

                                                                 // Remember this array address goes from 0 - 19, 20 is nul end of string terminator

   

 

   

unit8 pTr = 0;                                         // We will use this as array pointer

   

char CharRecv = 0;

   

.

   

.

   

          for ( ;; ) {

   

                   CharRecv = UARgetdata (whatever name of function is( );

   

                   MyRxData[ pTr ] = CharRecv;

   

                   pTr = ( pTr == 19 ) ? 0 : pTr + 1;        // Test for end of array, reset to 0 if it is

   

        }

   

 

   

And attached a treatise on pointers.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Thanks dana for the file,

0 Likes