10 Replies Latest reply on Aug 7, 2013 5:28 AM by DaKn_263916

    RS232 Fail test

      I just received a PSoC 4 unit to evaluate for a potential project/product. I installed creator 2.2 and I have been looking at videos and examples online.


      I tried creating a simple rs232 comunication test. Receive something from an external source and then append a little string to it and send it back.


      I must be missing something, bacause I can't get it to work. I assigned TX to P0.5 and RxP0.4.


      The Rx input pin is set to High Impidance Digital [low(0)]
      Tx is set to Resistive pull up. [I tried different options, not sure what to use].


      I would appreciate any help I could get. Also any information about training resources.


      The C code looks like this




      #include <device.h>


      void main()
          /* Place your initialization/startup code here (e.g. MyInst_Start()) */
          uint8 ch;
          UART_1_PutString("Testing RS232 :");
          /* CyGlobalIntEnable; */ /* Uncomment this line to enable global interrupts. */
              /* Place your application code here. */
              ch = UART_1_GetChar();//UartGetChar();
              //printf("test %c \n",ch);
              if (0u != ch)
              UART_1_PutString("got this ="+ch);

        • 1. Re: RS232 Fail test

          I forgot to mention that I connected the signal ground (rs232) to pun GND from J3.
          [I do not want to set the board as a bridge as it's suggested on the Pioneer kit guide, since the deviced where I plan to use it, doesn't have the USB option. ]


          For testing I am using a terminal program, and trying to send/receive something. 9600,8,n,1

          • 2. Re: RS232 Fail test

            The pioneer kit does not have a RS232 translator on it to get


            the levels necessary for the physical layer to talk to a PC.


            Unless you are doing a loopback test at the CMOS interface


            you cannot get the PC to talk to the UART over RS232.




            There are a plethora of RS232 translator chips, and you can always


            google "RS232 PC Interface" and do it with discretes. Or use a USB


            to RS232 dongle on PS side.




            Regards, Dana.

            • 3. Re: RS232 Fail test

              Hi Dana,


              Thank you for the reply. Just to be clear.


              Does this mean I would need a ttl shifter (Like this https://www.sparkfun.com/products/449)


              In the past I have used a MAXIM 232cpe, would either of this two options work for me? 


              Also what would be the maximum number of UARTs [rs232] that I should be able to defined? [I think I read that PSoC 4 had 2 UARTs] can I only define 2 or can the board "play some trics" to expand that number? 




              Thank you so much for your help,





              • 4. Re: RS232 Fail test
                        Hi, Something for you.   
                1) Permit global interrupt, user module might be use it.   
                2) I think, Tx pin might be Strong drive and initial value is high,   
                It would be better.   
                3) What is this? [ UART_1_PutString("got this ="+ch); ]   
                This is a C language, not have string class as C++   
                • 5. Re: RS232 Fail test

                  Maxim 232 excellent choice.




                  As far as max UARTs, take a look at the software UART and its API sizes.


                  Uses no UDB resources.




                  Regards, Dana.

                  • 6. Re: RS232 Fail test

                     UART_1_PutString("got this ="+ch);


                    is correct C, but does not do what you expect,


                    Use two statements, one to send the fixed text as a string and one to send the character as a byte.





                    • 7. Re: RS232 Fail test

                      There are some UDBs within the PSoC4 which can be used to build additional hardware. Try to implement one or two UART modules, connect the pins (Needed to prevent the UARTs from getting optimized-out) and see if the project fits, I did not try that yet.





                      • 8. Re: RS232 Fail test

                        Thank you for your comments. I added a MAX232xxx and I had communication two ways after that. The buffer seemed to be limited to 4bytes. I tried to just change the component (UART) buffer size, but that seems to requiere the use of interrupts.


                        Are there any examples of the use/implementation of this interrupts? or use larger string messages?


                        Thank you for your help,





                        • 9. Re: RS232 Fail test

                          I normally use a ring buffer for RX and own interrupt RX routine. 

                          • 10. Re: RS232 Fail test

                            When extending the buffer to more than 4 bytes will start an INTERNAL interrupt procedure, so there is no need (except for enabling global interrupts) for you to act.


                            The routines are blocking, so there is no need to increase the buffer. The routine will return when all bytes are sent.


                            HL applied for a different approach we always suggest here since it is a VERY good exercise and is rather helpful:


                            Write an interrupt driven routine that accepts characters from UART in a (so called) circular buffer.


                            Same (or similar) for ta circular buffer from which characters are fetched an transferred via UART.







                            • 11. Re: RS232 Fail test

                              3) What is this? [ UART_1_PutString("got this ="+ch); ]




                              You cannot concatenate strings or other to a string this way in C.


                              Convert the numeric to a string, then use




                              char *cstrcat(char *dest, const char *src); in the extended


                              library to concatenate the strings. Don't forget to size the receiving


                              string array to total length expected + 1 for nul termination character.




                              Regards, Dana.