Working with uart

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

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

0 Likes
15 Replies
Anonymous
Not applicable

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...

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Anonymous
Not applicable

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

0 Likes
lock attach
Attachments are accessible only for community members.
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

Half/Full Duplex cable use the same wiring.

   

 

   

Wiring attached.

   

 

   

Regards, Dana.

0 Likes
Anonymous
Not applicable

Hi,

   

     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.

   

 

   

Regards,

   

Aniruddha

0 Likes
Anonymous
Not applicable

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

0 Likes
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

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

   

oh..i realise only zip files can be attached

0 Likes
Anonymous
Not applicable

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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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

   

Bob

0 Likes
Anonymous
Not applicable

 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

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

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.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

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.

0 Likes
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

@Dana

   

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.

   

 

   

Bob

0 Likes
ETRO_SSN583
Level 9
Level 9
250 likes received 100 sign-ins 5 likes given

I suppose we are getting down to an individuals discipline. I am a commenter,

   

and re-examine them as I go along. Especially in light that comments reflect,

   

or should reflect, HW peculiarities that  a code piece may not. After all in this

   

day and age we take API's and apply them based on their description, not a

   

thorough examination of underlying HW. Otherwise we would still be working with

   

4 bit processors and not yet beyond simple calculator applications.

   

 

   

Your point, however, is not lost on me. My reviews do show up comments no longer

   

accurate. But that goes back to personel habits, pressure to release, time for that

   

trip to Mars........This is why humans must be replaced with machines.

   

 

   

Regards, Dana.

0 Likes