check for stop bit on RS232

Posted on 2004-10-28
Last Modified: 2010-04-15
How does one check for a stop bit in .c?
i want:
on rx (check input FIFO for data)
        if in data not stop-bit
           then append to a char_array/string
        else reset timer to check again.

#1 can someone verify that a Stop-bit comes across as a NULL character?

..... actually, if that is the case i guess that makes my question NULL :)
thanks for the quick answer.
Question by:bythefsh
    LVL 55

    Expert Comment

    by:Jaime Olivares
    There is not a standard software way to detect stop bit. Because stop bit is not designed originally to do what you want to do.
    Any alternative is highly system dependent and extremely unportable.
    LVL 45

    Expert Comment

    Hi bythefsh,

    Stop bits are really timing bits so they have no meaning in a data sense.  They are simply place holders on a serial line so that data arrives at the correct time.

    Assume that you wanted to send a string of several ASCII code 0x01s (8-bit integer 1).  Conceptually, the string of bits looks like:


    But the protocol may have stop bits defined.  If one stop bit is defined, then the string of bits more closely resembles


    If two stop bits are define, then the string of bits resembles:


    The stop bits merely align the data stream so that the start of each byte is received at the proper time.  The stop bits have no meaning as data.


    LVL 55

    Expert Comment

    by:Jaime Olivares
    As an alternative, you can use a special character, to acomplish what you want to do.
    Maybe some one of low ascii character codes like ASCII 22 (SYNC)
    Have a look to traditional ascii code usage at:
    LVL 22

    Accepted Solution

    It's not your job to look for the stop bit, the UART does this for you.

    Once it's gotten all the data bits in a byte and sees the proper stop bit, the UART raises a flag saying "The latest charafcter has all arrived".  

    It's your job to keep looking for that "data ready" bit and when you see it, read the data byte.

    See your UART spec sheets for more info.


    There are some poverty-stricken computers that have to look for the stop bit, but they also have to look for the start bit and the data bits too.   Hope this isnt your case.

    LVL 17

    Assisted Solution

    Usually Frame error flag is set if there were no stop bit in a received sequence of bits.

    Author Comment

    thanks i get it now.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    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…
    Preface I don't like visual development tools that are supposed to write a program for me. Even if it is Xcode and I can use Interface Builder. Yes, it is a perfect tool and has helped me a lot, mainly, in the beginning, when my programs were small…
    Video by: Grant
    The goal of this video is to provide viewers with basic examples to understand and use for-loops in the C programming language.
    The goal of this video is to provide viewers with basic examples to understand and use switch statements in the C programming language.

    884 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

    18 Experts available now in Live!

    Get 1:1 Help Now