14 Replies Latest reply on Jun 27, 2019 9:07 PM by AH_96

    UART PROBLEM

    BUTA_1301626

      My RF module works with UART. I'm using TX UART for the transmitter side.

      I would like to send [0x55,0x55,0x55,0x55,0x55,0x00,0x00,0x00,0x00,0x00,0xFF, 0xFF, 0xFF, 0xFF, 0xFE, 0xAB, 0xBC, 0xCD] with the help of UART.

      I use the program I added.

      but I can't get the result I want. Where am I making a mistake?

        • 1. Re: UART PROBLEM
          NoriakiT_91

          What baud rate are you going to use?

          As the UART_1 component says in its configuration utility tool, the baud rate is set to 2500bps.

          GS004132.png

           

          If you want to use 57600bps there are two solutions.

           

          SOLUTION 1 :

          Set the Clock_1 frequency to 57600*8=460,800Hz as follows.

          GS004133.png

          In this case, the actual baud rate becomes 57692bps

          GS004134.png

           

          SOLUTION 2 :

          Configure the UART_1 component to use an internal baud rate clock.

          GS004135.png

          Then specify the expected baud rate.

          GS004136.png

           

          Regards,

          Noriaki

          • 2. Re: UART PROBLEM
            NoriakiT_91

            Additional hint.

             

            If you want to receive a character 0x00, use UART_1_GetByte() instead of UART_1_GetChar()

             

            Regards,

            Noriaki

            • 3. Re: UART PROBLEM
              BUTA_1301626

              It gives error when I use this code."UART_1_GetByte() "

              .\ARM_GCC_541\Debug\main.o: In function `main':

              C:\Users\TOSHIBA1\Desktop\UART_Tx01\UART_Tx01.cydsn/main.c:56: undefined reference to `UART_1_GetByte'

              collect2.exe: error: ld returned 1 exit status

              The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

              --------------- Build Failed: 06/18/2019 09:39:44 ---------------

              • 4. Re: UART PROBLEM
                BUTA_1301626

                I tried them all separately. but the result is the same.

                • 5. Re: UART PROBLEM
                  NoriakiT_91

                  Sorry, I was looking into the RX side project.

                  The UART TX has 4 bytes of FIFO as default.  When the FIFO is exhausted, the FIFO overwritten and unexpected TX output will be observed.

                   

                  This is because the function UART_1_WriteTxData() does not block even if the FIFO is FULL.

                   

                  SOLUTION 1 :

                  Check the FIFO status by the function UART_1_ReadTxStatus() before calling the UART_1_WriteTxData()

                  while (!(UART_1_ReadTxStatus() & UART_1_STS_FIFO_NOT_FULL));
                  UART_1_WriteTxData(0xAA);
                  

                  while loops are required for all _WriteTxData() function.

                   

                  SOLUTION 2 :

                  Use blocking function UART_1_PutChar() instead of UART_1_WriteTxData()

                  CPU waits until the FIFO is not FULL.

                   

                  Regards,

                  Noriaki

                  • 6. Re: UART PROBLEM
                    BUTA_1301626

                    It gives error when I use this code.

                    arm-none-eabi-gcc.exe -mcpu=cortex-m3 -mthumb -I. -IGenerated_Source\PSoC5 -Wa,-alh=.\ARM_GCC_541\Debug/main.lst -g -ffunction-sections -ffat-lto-objects -O0 -c main.c -o .\ARM_GCC_541\Debug\main.o

                    main.c: In function 'main':

                    main.c:56:35: error: 'UART_1_STS_FIFO_NOT_FULL' undeclared (first use in this function)

                    while  (! (UART_1_ReadTxStatus()& UART_1_STS_FIFO_NOT_FULL));

                                                      ^

                    main.c:56:35: note: each undeclared identifier is reported only once for each function it appears in

                    The command 'arm-none-eabi-gcc.exe' failed with exit code '1'.

                    --------------- Build Failed: 06/18/2019 10:36:17 ---------------

                     

                     

                    Which one do I need to choose in this window?

                    TX on TX complate

                    TXon FIFO EMPTY

                    TXon FIFO FULL

                    TXon FIFO NOT FULL

                    • 7. Re: UART PROBLEM
                      BUTA_1301626

                      Ekran Alıntısı1.JPG

                      When I use UART_1_PutChar () it changed as in the figure.

                      • 8. Re: UART PROBLEM
                        NoriakiT_91

                        I am very sorry.

                        It's a TYPO. "_TX" is missing.

                         

                        while (!(UART_1_ReadTxStatus() & UART_1_TX_STS_FIFO_NOT_FULL)) ;
                        UART_1_WriteTxData(0xAA);  
                        

                         

                        Regards,

                        Noriaki

                        • 9. Re: UART PROBLEM
                          BUTA_1301626

                          I think there's a mistake.

                          Ekran Alıntısı1.JPG

                          The correct logical output should be as follows.

                          Ekran Alıntısı2.JPG

                          I can't find where the error is.

                          • 10. Re: UART PROBLEM
                            NoriakiT_91

                            As the UART protocol, each byte is consisting of START BIT, DATA BITS, and STOP BITS as the "TX" signal of the following figure from the UART datasheet.

                            GS004139.png

                            If you don't want to have START BIT and STOP BITS, Shift Register may be used.

                            Please refer the "Shift Register" component.

                             

                            Regards,

                            Noriaki

                            • 11. Re: UART PROBLEM
                              BUTA_1301626

                              I don't want to use start and stop bits. How do I use Shift Register where.

                              Can you help with this?

                              Regards,

                              • 12. Re: UART PROBLEM
                                NoriakiT_91

                                I have created a project using a Shift Register.

                                Please note that I didn't debug by oscilloscope.  I just confirmed the P1.6 as DC output.

                                 

                                Regards,

                                Noriaki

                                • 13. Re: UART PROBLEM
                                  BUTA_1301626

                                  Ekran Alıntısı2.JPG

                                  I think there's a mistake somewhere. It doesn't look like we want results.

                                  Regards,

                                  • 14. Re: UART PROBLEM
                                    AH_96

                                    Hi


                                    Please try the attached program and check if it meets your requirement.

                                     

                                    Thanks and regards

                                    Harigovind