9 Replies Latest reply on Oct 18, 2012 8:22 AM by ki.leung

    UART problem

    gopalakrishnan.varadappan

      Hai,

         

      i am tring to communicate from PC hyperterminal to PSOC 3. I configured the UART in interrupt mode. I am printing the received character on the LCD screen. when i type '1' on the hyperterminal, i could receive the '1' (49 ascii) at the UART. But when type '1' repeatedly,  it receives a meaningless character('177') alternatively. i attached the code also. Let me know whats my mistake (UART without interrupt mode works OK).

         

      From an old conversation i downloaded the bob's following example code and i tried  with my hyperterminal but iam getting the simillar error.

         

       

                                          
             
               UARTTest.cyprj.Archive02.zip       
         

       

         

       

         

      regards

         

      kavin

        • 1. Re: UART problem
          user_14586677

          It looks likle you are working with ES2 silicon, and an older version

             

          of Creator. I would advise you install Creator 2.1 for starters. If you

             

          'have an older ES2 silicon DVK, Cypress will upgrade it for free if

             

          you have not already done so.

             

           

             

          One alternative is there is an example project, receive with Hyperterminal,

             

          that you can try. Right click the UART component, "Find Example Project",

             

          and start a new project with it, and try that out. Baud is 57K, you might want

             

          to change that.

             

           

             

          Lastly I am sure you are using a RS232 level translator in the design, not a

             

          straight logic feed to the PC ? If not, MAX232 or a million varients are available.

             

           

             

          Regards, Dana.

          • 2. Re: UART problem
            user_1377889

            There are two issues I can see that will/may generate that error. Since you are using an old Creator-version I cannot update/correct your project, so you'll have to do that yourself.

               

             

               

            In the UART-module you have some features concerning 485 switched on and the "Address Mode" should be set to "None".

               

            You call

               

            you shouldn't do that, receiving a character will remove it from buffer. All LCD-routines use delay-loops and are time-consuming, so I think you are loosing characters (overrun). So I would suggest to write a circular buffer and retrieve all characters in the interrupt routine.

            Bob

               

             

               

            UART_ClearRxBuffer()

            • 3. Re: UART problem
              user_1377889

              The &$§ing forum-software wasn't able to insert that code-snippet at the right place. Move it up a couple of lines, please.

                 

               

                 

              Bon

              • 4. Re: UART problem
                gopalakrishnan.varadappan

                thaks for your reply.

                   

                I try to get update version of psoc and DVK.

                   

                Yes i used suitable rs232 level converters.

                   

                I tried with example project with 57k baud rate (file: UART_Rx) which uses non-interrupt mode of UART communication.

                   

                my problem comes when i try to read UART in interrupt mode with hyperterminal. When I used UART with 'non interrupt mode' than i could communicate without any error with hyperterminal. Instead of hyperterminal when i used Labview i could get correct result in the interrupt as well as in non interrupt modes of UART.

                   

                regards

                   

                kavin

                • 5. Re: UART problem
                  gopalakrishnan.varadappan

                  Sorry,

                     

                  when i used example project (UART-Rx) the uart receives only alternative characters. that is if type '1' ten times in hyperterminal the psoc uart receives five times. I tried with labview it receives all the ten times. Is there any problem with  hyperterminal?

                     

                  regards

                     

                  kavin

                  • 6. Re: UART problem
                    akshay.phatak

                    I see that you have used UART_ClearRxBuffer() API which seems unnecessary. When you read out the data using UART_GetChar() API, the pointer increments automatically and you need not clear the buffer again. Could you try removing that statement? May help.

                    • 7. Re: UART problem
                      gopalakrishnan.varadappan

                      i attached the file which i tested, i commanded the clesrbuffer, still behaves same way

                         

                      the problem comes only when using uart in interrupt mode.

                         

                      regards

                         

                      kavin

                      • 8. Re: UART problem
                        ki.leung

                         1. Your UART has rx buffer size of 5, Creator would generate an interrupt automatially( you can see that in the interrupt tab of your CYDWR file). Reduce the size to 4 (or smaller as you are not using it) and this interrupt would be disabled Your INT is not affected.

                           

                        2. You set a flag in your ISR and clear the flag in the main loop.I would suggest you disable RX interrupt before clearing the flag and re-enable it afterwards.( That may not be your problem, but just in case)

                           

                        3. Try a program called realterm ( freeware), which is much better then hyperterminal.

                        • 9. Re: UART problem
                          ki.leung

                           I mean

                             

                          2. You set a flag in your ISR and clear the flag in the main loop.I would suggest you disable RX interrupt before clearing the flag and re-enable it afterwards "IN THE MAIN LOOP".