1 2 Previous Next 15 Replies Latest reply on Aug 8, 2012 3:53 PM by DaKn_263916

    Working with uart

      Hey i tried working with uart.


      i copied the same code given in thedata sheet for software address detection. But the code is not working.


      can you help me out ....Every configuration is the same as given in data sheet.


      Secondly is there a problem using uart cable in half duplex mode either with pc or board to board

        • 1. Re: Working with uart

          i have one more question...


          what is tx-en pin that appers after selecting hardware tx enable....


          is it some sort of saying that "i am going to transmit"


          What is the use of it...

          • 2. Re: Working with uart

            Have a look at the definition for a RS232 interface, there you'll find RTS and CTS-signals. They have been used widedly to control as a hardware-protocol the direction of dataflow.


            Get your UART to work in the conventional way, that is without addressing-bytes and so on, your PC is not able to work with that. UART is a very simple data-transmission but needs a voltage-level shift when connected to a PC, usually a maxim chip and some Cs.


            When you got stuck, upload your project here, we'll have a look at it.


            To do so: Build -> Clean Project


            File -> Create Workspace Bundle(minimal)


            and finally upload the resulting .Zip-archieve.





            • 3. Re: Working with uart

              If you are using the -001 or -050 DVKs they both have RS232 Transceivers on them.




              Both ends of an RS232 link must be configured -




                   PC End - Usually flow control is turned off. Use Windows Device manager to set other parameters.


                   Make sure no other PC application software has a hook on port.




                   DVK end - Clock settings frequently source of problem. Make sure Transceiver power supply jumper


                   is in place, if there is one.




              Cable, normal swapped cable, Rx to Tx and Tx to Rx.




              Both previously mentioned boards have UART examples you can run.




              Regards, Dana.

              • 4. Re: Working with uart

                What do you mean swapped cable.......


                Half duplex does n.t work with the cable used for full- duplex??


                And if that is thecase i can just connect with two wires Tx - Rx and rx - Tx

                • 5. Re: Working with uart

                  Half/Full Duplex cable use the same wiring.




                  Wiring attached.




                  Regards, Dana.

                  • 6. Re: Working with uart



                         Please check for the following.


                    1. If you are using CY8CKIT-001 then check if UART is powered ON  (J10 jumper is connected) and check if TX and RX pins are connected properly


                    2. Short the UART Tx and RX pins on the kit and verify that the data that is transmitted is looped back


                    3. If step 2 works then there might be issue with the cable. Check for continuity on the cable and try again.




                    If above things do not work, then please attach your project and provide the Kit details.







                    • 7. Re: Working with uart

                      Hey i am attaching my half duplex projects take a look at them and review


                      Tell me is the code good enough .. does the industry approve it...lol

                      • 8. Re: Working with uart

                        i couldnt find the projrct i attached.. i am attaching it again


                        oh..i realise only zip files can be attached

                        • 9. Re: Working with uart

                          Can anyone take a look at the project and reply where i can develop myself...


                          if you dont want to embarass me you can mail me at microHari@yahoo.co.in

                          • 10. Re: Working with uart

                            I usually prefer a slightly different solution for interrupts in PSoC3 and 5:


                            There are the macros CY_ISR_PROTO(MyISR)  to declare an interrupt handler and


                            CY_ISR(MyISR) for the definition. The interrupt is started now with the API ISR_StartEx(MyISR).


                            This allows keeping theMyISR in one of my own files (main.c) and so I do not have to mangle in foreign (created) files.


                            Especially when I switch from PSoC5 to PSoC3 this would mean I have to re-insert the modifications I already did for the first version. Takes some time to find a bug, project after switching to a different device doesn't run any more.... arghhh!


                            You used the examples given in the datasheet and to be honest I am sure they can be improved.


                            To give you some criteria for a "Good" program: ("Working" is NO pont, a not-working program is as good as a piece of wood, although the latter burns longer)


                            What would your boss say? A good program is cheap


                            A good program can easily be adapted to different needs


                            A good program lives long


                            How to accomplish that? The magic word is "Readability". The better a program can be red, the easier it is understood, the better it can be mainained. This does not focus at the comments (in fact you changed your program, but did not change the comment - a usual mis-behaveour- . Use easy-to-read variable names, use capitals use functions use functions with talking names.


                            You have a construct as while(SomeThing){} // Wait for SomeThing


                            You may write while(SomeThing) Wait(); // No comment needed


                            See, what readability is? There's a book named "Clean Code", get hands on it!






                            Happy coding



                            • 11. Re: Working with uart

                               Thanks for the  comments...i will try to improve .... 


                               the code is not readable, i know ......and what about the logic of implementing halfduplex communication is it good enough or should it have been implemented in diffrent manner....


                              Thanks in advance

                              • 12. Re: Working with uart

                                I'm not in the position of a teacher giving you the grades for your program. I think you are the measure.


                                A problem can be solved with a program in several different ways. Which way is better? I prefer readability, others speed, some small code and so on.


                                You will have to look at your program yourself, start at the beginning, look at the cpoyrights. This is your program? So why is it copyrighted by Cypress? Because you did not change that text.


                                Start there, what does YOUR program do, when did you write it, and who are you and to whom belongs the rights.


                                THAT is quite more essential than to improve any logic within that project.





                                • 13. Re: Working with uart

                                  Just a general comment, can you read and understand what you wrote 6 months


                                  after completion of a project ? If you cannot, good chance nobody else can w/o


                                  great difficulty.




                                  Rule of thumb, for every code command character you write, did you write 5 in the


                                  comments of why you issued the command ? There is no magic standard for good


                                  code-i-fying, Look at examples on the web.




                                  Regards, Dana.

                                  • 14. Re: Working with uart



                                    Surprisingly (at least for me) one of the statements in the book "Clean Code" was not to use comments.


                                    The author gave two reasons for that:


                                    1st. When you change the program in 30% of all cases you forget to change the comment, resulting in a mismatch between what the program really does and what the comment says.


                                    2nd. You can write your programs in a way that no comment is needed, so you can ommit them. (Have a look at my post with the "Wait()"-function)


                                    I dislike most absolute restrictions as "NO Comments" but with my own (bad) experiences number 1 is a remarable fact. Since I like to express myself in written form (as you may recognise from my lengthy posts) the second point does not induce any difficulties for me.





                                    1 2 Previous Next