This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

INFO UART

Dear All,

Is possible to have informations on this code?

int sendchar (int ch) { /* Write character to Serial Port */

while (!(UxLSR & 0x20)); Why??

return (UxTHR = ch); Why??
}

Thanks

  • You forgot to mention what processor you are using.

    The data sheet or the user manual will tell you exactly what the symbols UxLSR and UhTHR means.

    But are you sure that you have the correct names?

    UxLSR normally stands for U0LSR, U1LSR, U2LSR, ... depending on what UART you need to access.

    If there is something you don't understand un the data sheet/user manual - please ask, and we can help you.

  • Sorry my cpu is LPC2378 but I not understand this line

    while (!(U1LSR & 0x20)); Why & 0x20??

    Thanks very much

    Carlo

  • because bit 5 (0x20 = 100000 binary) means something in U1LSR !
    this code

    while (!(U1LSR & 0x20));
    


    runs as long as that bit is not set.
    read your manual, please.

  • A quick peek in the user manual (that's the name of the "good stuff" for the LPC23xx chips) will quickly find the definition for U0LSR, U1LSR, U2LSR and U3LSR.

    The first match if you search will also tell you the symbolic name for the bit 0x20. A little extra search and you will get a full paragraph what the bit represents, and then it will be obvious why the example code waits.

    The only way to really learn is by spending time to learn. We can't learn for you.