Solved

Serial communications

Posted on 2004-04-20
19
2,002 Views
Last Modified: 2008-02-01
From device communication protocol:
The controller UART is configured to use the standard 4800 bps communication speed using 1 startbit, 8 databits, 1 even parity bit and 1 stopbit (lsbit first).

I am trying to talk with this device using COM terminal program (for now, unsuccessful). All COM terminals contain standard COM port parameters like speed, databits, patity, stopbit. But I don't understand two parameters from this protocol: "1 startbit" and "lsbit first". What does this mean?
0
Comment
Question by:AlexFM
  • 8
  • 3
  • 2
  • +4
19 Comments
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
lsbit first means least significatnt bit first.
0
 
LVL 45

Assisted Solution

by:Kdo
Kdo earned 100 total points
Comment Utility
Hi Alex,

start/stop bits are really just "timing" bits that occur in the bitstream.

SSSDDDDDDDDPsssss


In the imaginary sequence above, SSS indicates that there are three start bits, and sssss indicates that there are 5 stop bits.  (Just an example -- you wouldn't do this in real life.)  Identifying the number of start/stop bits tells the UART where in the bitstream the data lies.

lsbit is short for Least Significant Bit.


Kent
0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
the data field is flanked on either side by startbit and stopbit.

1 startbit means 1 bit will be used to demarcate the start of the frame.
0
 
LVL 2

Assisted Solution

by:anupvijay
anupvijay earned 50 total points
Comment Utility
Hi AlexFM,

1 start bit means that the start of transmission is indicated by a bit '0' and similarly stop bit would be '1' which indicates stop
of data transmission.

lsbit first means that the LSB bit is transmitted first. This is similar to the little endian system I guess.
Does it make sense ? Other experts please correct me if I am wrong. If I am correct then does this point towards any
thing that tells you why your communication is not working ?
All the best.

Cheers.
0
 
LVL 48

Author Comment

by:AlexFM
Comment Utility
What is interesting for me now - I am trying to talk with this device, and all terminal programs I try don't have such settings. I don't know whether I am OK or not, this may be also hardware problem which should be solved by HW engineers. For example, I run Windows Hyperterminal, and see speed, databits, patity and stopbit options. But I don't see "1 startbit" and "lsbit first" options. Can I be sure that I am OK? Are these parameters supposed to have such values in any standard COM terminal?
0
 
LVL 2

Expert Comment

by:anupvijay
Comment Utility
Before submitting there were no other comments.....sorry if my answer is a repetition.....
The net age :-)
0
 
LVL 45

Expert Comment

by:Kdo
Comment Utility
Hi Alex,

The UART should "hide" most of the data formatting issues from your application.  By telling the UART the number of start/stop bits, parity, etc you're pushing all of the I/O and timing related issues to the hardware, microcode, BIOs, etc levels.

I'm not familiar with a UART differentiates between LSB and MSB.  (They may well exists -- I just don't know about them.)  As long as both devices are using LSB or MSB it shouldn't matter.


As an aside, I once dealt with a device that used 1.5 stop bits.  I didn't know this when I first started coding for it and blame it for much of my hair loss.  :)


Kent
0
 
LVL 9

Assisted Solution

by:ankuratvb
ankuratvb earned 100 total points
Comment Utility
Hi Alex,

I dont know how much of this would be useful for you but

http://www.beyondlogic.org/serial/serial.htm

has an excellent description of serial communicationa and its nuances.

0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
Hey Kent,

I just noticed that in hyperterminal settings as well.
Indeed surprising.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
I actually can understand the logic of allowing to set the length of the stop bit and not allowing to change the length of the start bit. As is the case with Hyperterminal

Either you allow both or you dont allow both.

0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
>I actually can

I actually can't.


0
 
LVL 10

Expert Comment

by:Mercantilum
Comment Utility
Hi Alex,
Please have a look to this nice tool
http://www.experts-exchange.com/Q_20957961.html
0
 
LVL 11

Assisted Solution

by:griessh
griessh earned 100 total points
Comment Utility
Alex

some more info:

RS232 serial communication is an asyncronous communication, that means the receiver does not know about the number of data bits sent. But both transmitter and receiver know (through the setup) about some frame information.
- There is 1 start bit which is always 0
- There is a defined number of stop bits (1, 1 1/2, 2)
- There is a (possible) parity bit
- The LSB (least signifiacnt bit) is send first
When the receiver 'sees' a start bit it knows that a new 'word' is to be transmitted. With the baud rate the time of 1 bit is specified. Once the line is in a 'mark' state created by the stop bit the receiver can wait for a new star-bit. The time between 'words' is not defined.
That should answer your question about start bit and LSB first.

======
Werner
0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
>There is 1 start bit which is always 0

If that is the case,why is it that we can change the start bit's length using code(for some device) but not using hyperterminal.

0
 
LVL 11

Expert Comment

by:griessh
Comment Utility
A UART is hardware and can be configured to all kinds of settings (for example: nobody forces a UART to only support the standard transmission speeds) and has a superset of functions of what is needed for 'standard' serial communication.
RS232 communication is a defined way to communicate and specifies 1 start bit.

Check the datasheet of any 16550 derivate and you will be able to learn more about UARTS. I have no idea what UART Alex is using, but none of the 'standard' UARTS offer that startbit option.

=====
Werner
0
 
LVL 48

Author Comment

by:AlexFM
Comment Utility
Thanks for the answers. Can I make conclusion from this that setting of speed, databits, patity, stopbit is enough, I don't need to care about startbit and lsbit settings, because they are always default, and if device doesn't answer, this is probably hardware program?
0
 
LVL 22

Accepted Solution

by:
grg99 earned 150 total points
Comment Utility
I've never heard of having more than one start bit, one and only one is the standard way to go.

The old 1940's teletypes needed 1.5 stop bits, as they were purely mechanical devices, with the receiving end perhaps running a few percent slower than the sending end.  The extra .5 stop bit would allow the receiver some breathing room to catch up.

When computers got into the act, the early UARTS couldnt do 1.5 stop bits, so 2 stop bits was a common option.

But I've never seen any choices in start bits!      It *may* be part of some of those new serial protocols used between chips.   See i2C and other two-wire and one-wire serial protocols.

If you're getting absolutely NOTHING, not even garbage, you probably need to do one or more of the below:

(1)  Strap the handshaking lines to their opposite friends.

(2)  Strap some lines HIGH.

(3)  Swap send and receive lines (2 and 3).

Many an afternoon I've wasted doing just the above.

Nowadays you can buy a $9.95 RS-232 "breakout box", which has nice wires and pins and LED's to indicate what's going on.
You'll probably need one of these if you're not quickly lucky just swapping 2 and 3.




0
 
LVL 11

Expert Comment

by:griessh
Comment Utility
Alex

The breakout box grg99 is  alife saver if you do that kind of work more often.

What type of handshake are you using? software ? hardware? none?
0
 
LVL 9

Expert Comment

by:ankuratvb
Comment Utility
Thanx griessh for that information.

I just checked that out on beyondlogic's site:

http://www.beyondlogic.org/serial/serial1.htm#40

This is what they say:

The RS-232 line, when idle is in the Mark State (Logic 1). A transmission starts with a start bit which is (Logic 0). Then each bit is sent down the line, one at a time. The LSB (Least Significant Bit) is sent first.

0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you thought about creating an iPhone application (app), but didn't even know where to get started? Here's how: ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ Important pre-programming comments: I’ve never tri…
An Outlet in Cocoa is a persistent reference to a GUI control; it connects a property (a variable) to a control.  For example, it is common to create an Outlet for the text field GUI control and change the text that appears in this field via that Ou…
Video by: Grant
The goal of this video is to provide viewers with basic examples to understand and use while-loops in the C programming language.
The goal of this video is to provide viewers with basic examples to understand and use conditional statements in the C programming language.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now