6 Replies Latest reply on May 16, 2014 5:20 AM by ctm.ctm

    UART Communication

    dennis.k.thomas

       Hello,

         

       

         

      I am using two UARTs in my system.One UART is for transmission and one UART is reception in duplex mode.

         

       

         

      Here is a part of my Program

         

       

         

      for(;;)

         

          {

         

              /* Place your application code here. */

         

      //Wait for command

         

      recv_byte=0;

         

      UART_1_WriteTxData(0x0d);UART_1_WriteTxData(0x0a);

         

      UART_1_PutString("Company Name.......");

         

               CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);

         

      CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);

         

      UART_1_PutString("auoto Zero  => Z");

         

                CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);

         

      UART_1_PutString("Measure     => M");

         

             CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);

         

      UART_1_PutString("Setup       => S");

         

              CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);CyDelay(20);

         

      UART_1_PutString("display oN  => N");

         

               CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);CyDelay(20);

         

      UART_1_PutString("display oFf => F");

         

               CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);CyDelay(20);

         

      UART_1_PutString("display Test=> T");

         

               CyDelay(20);UART_1_WriteTxData(0x0d);CyDelay(20);UART_1_WriteTxData(0x0a);CyDelay(20);

         

      CyDelay(20);

         

      .

         

      .

         

      .

         

      .

         

      .

         

      so on.............and I am displaying all these datas through serial port in Hyperterminal in a PC

         

      the problem that now I am facing is,there is only one or two lines is displaying or transmitting.After that the execution of the program is in a Pause state.

         

       

         

      Can anyone please tell what is the reason for this problem ?

        • 1. Re: UART Communication
          user_1377889

          Would you mind to zip and post your complete project here, so we can have a look at all possibilities that cause your problem?

             

          If you "Clean" your project before zipping it becomes smaller, there is a 2MB limit for uploads afaik.

             

          Bob

          • 2. Re: UART Communication
            user_1377889

            At (very) first sight I can see, that you use the WriteTxData() API without checking the transmitter status. This will resullt in errorneous transmission of data..

               

            What are your Delays for? Waiting until the data is transmitted? It will go better checking the status.

               

            Use the PutChar() API instead, which will block, if the UART is busy or the transmit-buffer / FiFo is full.

               

            The PutString() API already blocks, so there's no need to wait for it.

               

             

               

            Bob

            • 3. Re: UART Communication
              ctm.ctm

              Hi every body! Help me!!!

                 

              I have a prolem when PSoC conect to PC via RS232 circuit (UART).

                 

              I need:

                 

              - PSoC recieve data from PC send (char,string...).

                 

              - If PSoC receive character 'a', turn on led; else turn off led.

                 

              Pin:

                 

              P0.4: RX

                 

              P0.5: TX

                 

              P0.3: led

                 

              Currently, hardware is fine. But code not work as i need!

                 

              I checked configuration PSoC, code of my project.

                 

              I upload my project for every body.

                 

              Can you help me, please?

                 

              I do this project because i will do project: 

                 

              -P0.4 receive data (char, string...) from pC.

                 

              -P0.5 forward data that P0.4 received to PC.

              • 4. Re: UART Communication
                user_14586677

                Just a check, you have a RS232 transceiver connected to your PSOC

                   

                to develop RS232 levels for the PC serial interface ?

                   

                 

                   

                Regards, Dana.

                • 5. Re: UART Communication
                  user_14586677

                  I see you are driving LED by setting port to high, implying LED wired from Vss to

                     

                  a series R to pin. The pin cannot source as much current as sink, better you connect LED

                     

                  to Vdd to series R to port, and turn it on driving pin to "0", Vss.

                     

                   

                     

                  Regards, Dana.

                  • 6. Re: UART Communication
                    ctm.ctm

                     Hi Dana,

                       

                    About RS232 circuit which i used: it is good because i coded a example to test.

                       

                    - TX on PSoC transmit data (char, string) to PC, PC received data and show well.

                       

                    - But RX on PSoC can't work. 

                       

                    (I'm using software: Terminal 1.9b to check communication between PSoC and PC)

                       

                    I use 1 led to test, not more. I think project has no prolems with that led.

                       

                    Can you check about configuration of my project, please?

                       

                    Or, Is code incorrect?

                       

                    I have just studied PSoC!

                       

                    Many thanks!