1 2 Previous Next 15 Replies Latest reply on Apr 4, 2014 8:46 PM by juan.rico

    Uart RX PSoC3

    juan.rico

      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

        • 1. Re: Uart RX PSoC3
          user_246598725

          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

          • 2. Re: Uart RX PSoC3
            user_1377889

            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

            • 3. Re: Uart RX PSoC3
              user_14586677

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

                 

              Goto "File", "Example Project" -

                 

               

                 

               

              • 4. Re: Uart RX PSoC3
                user_14586677

                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.

                • 5. Re: Uart RX PSoC3
                  user_78878863

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

                  • 6. Re: Uart RX PSoC3
                    user_14586677

                    The -001 kit also has a RS232 transceiver.

                       

                     

                       

                    Regards, Dana.

                       

                     

                       

                     

                    • 7. Re: Uart RX PSoC3
                      juan.rico

                      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

                      • 8. Re: Uart RX PSoC3
                        user_1377889

                        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

                        • 9. Re: Uart RX PSoC3
                          user_14586677

                          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.

                          • 10. Re: Uart RX PSoC3
                            juan.rico

                            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

                            • 11. Re: Uart RX PSoC3
                              user_1377889

                              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

                              • 12. Re: Uart RX PSoC3
                                user_14586677

                                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

                                   

                                        }

                                • 13. Re: Uart RX PSoC3
                                  juan.rico

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

                                  • 14. Re: Uart RX PSoC3
                                    user_14586677

                                    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.

                                    1 2 Previous Next