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

Usage of UART0

I'm having trouble using UART0 correctly. I'm writing a value in SBUF0 and after that I'm putting the new value in SBUF0 into a var. When I look at the value in that var, it's empty. How can I put something correctly in this buffer and reading from it again?

I also noticed, that when sending to SBUF0, it takes some time for 1 byte to transfer. This is about over 2 seconds. Is this normal and if so, why is it so slow?

  • hi,

    How can I put something correctly in this buffer and reading from it again?

    Your problem is that SBUF is not only one register. For this point of view, let say that SBUF is made with two registers: one for transfer (when you write to it) and another for receive (when you read from it). Indeed they share the same memory address in SFR area but are selected by read or write operation.
    So you cannot read value which has been put to SBUF because you read another register then when write to.

    As about the speed so please post your initialization routines and indicate the OSC frequency as well. Then it will be possible to find the problem.

    Regards,
    Oleg