7 Replies Latest reply on Sep 19, 2016 2:07 AM by user_1377889

    PRoC 4 UART receive problem

    typoon_1686656

      Q1: I have problem when I am writing a UART Tx and Rx program for the PRoC 4 (CYBL10573) device. I found that all the example project used a function "UART_UartGetChar" in the generated driver to receive a byte from the UART. However this function will ignore number 0 in the receiver part. I think it assumes it is receiving ASCII string. However in my case I am receiving decimal value so I need to receive 0.

         

      How can I check if any data is received instead of  using the "UART_UartGetChar" function?

         

      Q2: In the examples, they are not using receive interrupt. I tried to enable the "RX FIFO not empty" internal interrupt, and trace the stack, I found that it will call "UART_SPI_UART_ISR" and then wait forever here. How can I use the interrupt?

         

      Q3: The generated code is so complicated that it is very difficult to follow by the code. And most of the time the example project is too simple. Actually I have encountered other problem before and I want to do some study before asking question here or finding the support engineer. Is there any documents that describe how to use the generated driver code? Or a user manual for the device?

         

       

         

      Thank you.

        • 1. Re: PRoC 4 UART receive problem
          user_1377889

          A1: There is an API named UART_SPIUartGetRxBufferSize() which gives you the amount of bytes still in buffer. As long as non-zero, you can retrieve the data by using UART_UartGetByte(). Easiest configuration is to use an Rx buffer size of 20 to 80 and let the component handle the interrupt itself.

             

          A2: Common error is not to clear the component's interrupt, program will loop in handler infinitively.

             

          A3: Government health warning: never read the generated .c files, there is absolutely no need for. ;-)

             

          Instead I would suggest to read the component datasheet to get a feeling how it is designed to work. Every component available for your selected PSoC is listed in the Component Catalog window, the datasheet is always just a mouse-click away.

             

           

             

          Bob

          • 2. Re: PRoC 4 UART receive problem
            michal.reznicek_1607246

            Hello, Bob 

               

             

               

            I have small problem.

               

             

               

            I wrote small project for distance measuring by  sonar sensor HC-SR04.

               

            The distance is mesured using timer (numbetr of samples is represent distance) and I would like send it to PC (Matlab) using Uart.

               

            I used CY8CKIT-049-42xx

               

             

               

            The problem is that, I don't see any received data in hyperterminal but data are transmiting (I try measure pulses at output Tx pin using osciloscope and the all is well).

               

             

               

            Can you help me?

               

             

               

             

               

            Thank you wery wery much.

               

             

               

            Michal

            • 3. Re: PRoC 4 UART receive problem
              typoon_1686656

              Hi Michal,

                 

              I guess it is better to open another thread to ask a new question.

                 

              Anyway, firstly I think you have to check again to verify whether the transmit signal is correct, for example the baudrate, start/stop/parity bit etc. If everything is correct, it is not the problem of the Cypress chip, it is the problem of the receiving side, that is your computer.

                 

              Then please check whether you have used a correct TTL-to-computer converter. you can check the converter by wire its transmit pin to the receive pin, send something on the hyperterminal and check whether you receive the same thing.

                 

              When you connect the converter to your board, remember to wire the RX pin of the converter to the TX pin of your board. And remember to wire the "ground" pin.

              • 4. Re: PRoC 4 UART receive problem
                user_1377889

                Hi Michal.

                   

                You will have to use the buit-in USB-UART bridge of your CY8CKIT-049-42xx board. This requires the Rx and Tx pins to be set to P4_0 and P4_1. Have a look into the kit schematics. No converter needed for this.

                   

                Open windows device manager, look at the com-ports and then plug in your board. A new com-port will appear. Not its number and configure your terminal emulator accordingly.

                   

                Be sure just to send ASCII data. If still in doubt, post your actual project.

                   

                 

                   

                Bob

                • 5. Re: PRoC 4 UART receive problem
                  michal.reznicek_1607246

                  Hello Bob,

                     

                  I'm used the miniprog3 for programing. The miniprog was conected to SWD. The UART was conected to P4.1,P4.0 and GND directly to my PC-UART (9 canon in dockstation). I see the com port in my device manager. 

                     

                  I'm cant find where is error :(.

                     

                   

                     

                  Thank you very very much for your help.

                  • 6. Re: PRoC 4 UART receive problem
                    michal.reznicek_1607246

                    The USB bridge is working well. 

                       

                    Why is not work direct connection Rx-TX to UART in dock station?

                    • 7. Re: PRoC 4 UART receive problem
                      user_1377889

                      You can easily destroy your PSoC by connecting it directly to your PC 9-pin com port. The reason is that the PC uses RS232 voltage levels which are +- 12V. When you want connect directly as Typoon already said: "Then please check whether you have used a correct TTL-to-computer converter. ". There are chips for interfacing as the well-known MAX232.

                         

                       

                         

                      Bob